X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fhttp.c;h=aec359316291b16426358e817d359db28d6ea399;hb=3229700a4bfec42f1ca75f1a3526d2aaf8070469;hp=8321bb3b818f4966738cfa19af23431191534906;hpb=f9fd1939f30660831f6390a91839357133e005ea;p=pazpar2-moved-to-github.git diff --git a/src/http.c b/src/http.c index 8321bb3..aec3593 100644 --- a/src/http.c +++ b/src/http.c @@ -878,13 +878,13 @@ static void http_error(struct http_channel *hc, int no, const char *msg) static void http_io(IOCHAN i, int event) { struct http_channel *hc = iochan_getdata(i); - - switch (event) + while (event) { - int res, reqlen; - struct http_buf *htbuf; - - case EVENT_INPUT: + if (event == EVENT_INPUT) + { + int res, reqlen; + struct http_buf *htbuf; + htbuf = http_buf_create(hc->http_server); res = recv(iochan_getfd(i), htbuf->buf, HTTP_BUF_SIZE -1, 0); if (res == -1 && errno == EAGAIN) @@ -933,12 +933,16 @@ static void http_io(IOCHAN i, int event) http_command(hc); } } - break; - case EVENT_OUTPUT: + } + else if (event == EVENT_OUTPUT) + { + event = 0; if (hc->oqueue) { struct http_buf *wb = hc->oqueue; - res = send(iochan_getfd(hc->iochan), wb->buf + wb->offset, wb->len, 0); + int res; + res = send(iochan_getfd(hc->iochan), + wb->buf + wb->offset, wb->len, 0); if (res <= 0) { yaz_log(YLOG_WARN|YLOG_ERRNO, "write"); @@ -955,7 +959,8 @@ static void http_io(IOCHAN i, int event) wb->len -= res; wb->offset += res; } - if (!hc->oqueue) { + if (!hc->oqueue) + { if (!hc->keep_alive) { http_channel_destroy(i); @@ -965,17 +970,19 @@ static void http_io(IOCHAN i, int event) { iochan_clearflag(i, EVENT_OUTPUT); if (hc->iqueue) - iochan_setevent(hc->iochan, EVENT_INPUT); + event = EVENT_INPUT; } } } - if (!hc->oqueue && hc->proxy && !hc->proxy->iochan) http_channel_destroy(i); // Server closed; we're done - break; - default: + } + else + { yaz_log(YLOG_WARN, "Unexpected event on connection"); http_channel_destroy(i); + event = 0; + } } }