From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=58490 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PPj8d-0004sk-9j for qemu-devel@nongnu.org; Mon, 06 Dec 2010 17:02:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PPj8b-0003z6-Mg for qemu-devel@nongnu.org; Mon, 06 Dec 2010 17:02:27 -0500 Received: from e31.co.us.ibm.com ([32.97.110.149]:53360) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PPj8b-0003yv-H3 for qemu-devel@nongnu.org; Mon, 06 Dec 2010 17:02:25 -0500 Received: from d03relay01.boulder.ibm.com (d03relay01.boulder.ibm.com [9.17.195.226]) by e31.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id oB6Lmlsp028678 for ; Mon, 6 Dec 2010 14:48:47 -0700 Received: from d03av05.boulder.ibm.com (d03av05.boulder.ibm.com [9.17.195.85]) by d03relay01.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id oB6M2Hps121400 for ; Mon, 6 Dec 2010 15:02:18 -0700 Received: from d03av05.boulder.ibm.com (loopback [127.0.0.1]) by d03av05.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id oB6M2H7Y003055 for ; Mon, 6 Dec 2010 15:02:17 -0700 From: Adam Litke In-Reply-To: <1291399402-20366-5-git-send-email-mdroth@linux.vnet.ibm.com> References: <1291399402-20366-1-git-send-email-mdroth@linux.vnet.ibm.com> <1291399402-20366-5-git-send-email-mdroth@linux.vnet.ibm.com> Content-Type: text/plain; charset="UTF-8" Date: Mon, 06 Dec 2010 16:02:15 -0600 Message-ID: <1291672935.2213.6.camel@aglitke> Mime-Version: 1.0 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: Michael Roth 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 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? > + 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); > +} -- Thanks, Adam