From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=53681 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PPjdl-0003UU-8j for qemu-devel@nongnu.org; Mon, 06 Dec 2010 17:34:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PPjdk-0002J7-2x for qemu-devel@nongnu.org; Mon, 06 Dec 2010 17:34:37 -0500 Received: from e7.ny.us.ibm.com ([32.97.182.137]:41484) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PPjdk-0002J2-0Y for qemu-devel@nongnu.org; Mon, 06 Dec 2010 17:34:36 -0500 Received: from d01dlp01.pok.ibm.com (d01dlp01.pok.ibm.com [9.56.224.56]) by e7.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id oB6MH26a014931 for ; Mon, 6 Dec 2010 17:17:03 -0500 Received: from d01relay01.pok.ibm.com (d01relay01.pok.ibm.com [9.56.227.233]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id EFAFB72805B for ; Mon, 6 Dec 2010 17:34:33 -0500 (EST) Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id oB6MYXEZ405944 for ; Mon, 6 Dec 2010 17:34:33 -0500 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id oB6MYXgb003990 for ; Mon, 6 Dec 2010 17:34:33 -0500 Message-ID: <4CFD64F8.2070500@linux.vnet.ibm.com> Date: Mon, 06 Dec 2010 16:34:32 -0600 From: Michael Roth MIME-Version: 1.0 References: <1291399402-20366-1-git-send-email-mdroth@linux.vnet.ibm.com> <1291399402-20366-5-git-send-email-mdroth@linux.vnet.ibm.com> <1291672935.2213.6.camel@aglitke> In-Reply-To: <1291672935.2213.6.camel@aglitke> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [RFC][PATCH v5 04/21] virtagent: transport definitions and job callbacks List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Adam Litke Cc: agl@linux.vnet.ibm.com, stefanha@linux.vnet.ibm.com, Jes.Sorensen@redhat.com, qemu-devel@nongnu.org, aliguori@linux.vnet.ibm.com, ryanh@us.ibm.com, abeekhof@redhat.com On 12/06/2010 04:02 PM, Adam Litke wrote: > On Fri, 2010-12-03 at 12:03 -0600, Michael Roth wrote: >> +static void va_http_send_handler(void *opaque) >> +{ >> + VAHTState *s =&va_state->send_state; >> + enum va_http_status http_status; >> + int fd = va_state->fd; >> + int ret; >> + >> + TRACE("called, fd: %d", fd); >> + >> + switch (s->state) { > > Why is there a VA_SEND_START state when it always falls through to > VA_SEND_HDR? Is there any difference between these? > Nope, not at the moment. I'll stick with just _HDR for now, but if we ever need to do some initialization or anything before we start sending/reading that's what this would be for. >> + case VA_SEND_START: >> + s->state = VA_SEND_HDR; >> + case VA_SEND_HDR: >> + do { >> + ret = write(fd, s->hdr + s->hdr_pos, s->hdr_len - s->hdr_pos); >> + if (ret<= 0) { >> + break; >> + } >> + s->hdr_pos += ret; >> + } while (s->hdr_pos< s->hdr_len); >> + if (ret == -1) { >> + if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) { >> + return; >> + } else { >> + LOG("error writing header: %s", strerror(errno)); >> + goto out_bad; >> + } >> + } else if (ret == 0) { >> + LOG("connected closed unexpectedly"); >> + goto out_bad; >> + } else { >> + s->state = VA_SEND_BODY; >> + } >> + case VA_SEND_BODY: >> + do { >> + ret = write(fd, s->content + s->content_pos, >> + s->content_len - s->content_pos); >> + if (ret<= 0) { >> + break; >> + } >> + s->content_pos += ret; >> + } while (s->content_pos< s->content_len); >> + if (ret == -1) { >> + if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) { >> + return; >> + } else { >> + LOG("error writing content: %s", strerror(errno)); >> + goto out_bad; >> + } >> + } else if (ret == 0) { >> + LOG("connected closed unexpectedly"); >> + goto out_bad; >> + } else { >> + http_status = VA_HTTP_STATUS_OK; >> + goto out; >> + } >> + default: >> + LOG("unknown state"); >> + goto out_bad; >> + } >> + >> +out_bad: >> + http_status = VA_HTTP_STATUS_ERROR; >> +out: >> + s->send_cb(http_status, s->content, s->content_len); >> + qemu_set_fd_handler(fd, va_http_read_handler, NULL, NULL); >> +} >