[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] Re: [RFC][PATCH v5 04/21] virtagent: transport definitions
From: |
Adam Litke |
Subject: |
[Qemu-devel] Re: [RFC][PATCH v5 04/21] virtagent: transport definitions and job callbacks |
Date: |
Mon, 06 Dec 2010 16:02:15 -0600 |
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
- [Qemu-devel] [RFC][PATCH v5 01/21] Move code related to fd handlers into utility functions, (continued)
- [Qemu-devel] [RFC][PATCH v5 01/21] Move code related to fd handlers into utility functions, Michael Roth, 2010/12/03
- [Qemu-devel] Re: [RFC][PATCH v5 01/21] Move code related to fd handlers into utility functions, Jes Sorensen, 2010/12/07
- Re: [Qemu-devel] Re: [RFC][PATCH v5 01/21] Move code related to fd handlers into utility functions, Michael Roth, 2010/12/07
- Re: [Qemu-devel] Re: [RFC][PATCH v5 01/21] Move code related to fd handlers into utility functions, Jes Sorensen, 2010/12/07
- Re: [Qemu-devel] Re: [RFC][PATCH v5 01/21] Move code related to fd handlers into utility functions, Stefan Hajnoczi, 2010/12/08
- Re: [Qemu-devel] Re: [RFC][PATCH v5 01/21] Move code related to fd handlers into utility functions, Jes Sorensen, 2010/12/08
- Re: [Qemu-devel] Re: [RFC][PATCH v5 01/21] Move code related to fd handlers into utility functions, Stefan Hajnoczi, 2010/12/08
- Re: [Qemu-devel] Re: [RFC][PATCH v5 01/21] Move code related to fd handlers into utility functions, Jes Sorensen, 2010/12/08
- Re: [Qemu-devel] Re: [RFC][PATCH v5 01/21] Move code related to fd handlers into utility functions, Anthony Liguori, 2010/12/08
[Qemu-devel] [RFC][PATCH v5 04/21] virtagent: transport definitions and job callbacks, Michael Roth, 2010/12/03
[Qemu-devel] [RFC][PATCH v5 02/21] Add qemu_set_fd_handler() wrappers to qemu-tools.c, Michael Roth, 2010/12/03
[Qemu-devel] [RFC][PATCH v5 05/21] virtagent: base client definitions, Michael Roth, 2010/12/03
[Qemu-devel] [RFC][PATCH v5 03/21] virtagent: common code for managing client/server rpc jobs, Michael Roth, 2010/12/03