From 0209815ecb67520622b4e11a6c15b28f4b1dce8f Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 20 Dec 2006 23:31:24 +0000 Subject: [PATCH] Fixed problem with detection of end-of-stream for HTTP socket. Problem was that if errno happened to be EAGAIN and read returned 0, then errno was invalid (or has value of previous failed Unix call). Only if read returns -1, it's appropriate to check errno. --- src/http.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/http.c b/src/http.c index 401f5ae..48a2643 100644 --- a/src/http.c +++ b/src/http.c @@ -1,5 +1,5 @@ /* - * $Id: http.c,v 1.1 2006-12-20 20:47:16 quinn Exp $ + * $Id: http.c,v 1.2 2006-12-20 23:31:24 adam Exp $ */ #include @@ -517,7 +517,12 @@ static void http_io(IOCHAN i, int event) case EVENT_INPUT: htbuf = http_buf_create(); res = read(iochan_getfd(i), htbuf->buf, HTTP_BUF_SIZE -1); - if (res <= 0 && errno != EAGAIN) + if (res == -1 && errno == EAGAIN) + { + http_buf_destroy(htbuf); + return; + } + if (res <= 0) { http_buf_destroy(htbuf); http_destroy(i); @@ -532,7 +537,6 @@ static void http_io(IOCHAN i, int event) if (hc->state == Http_Busy) return; - if ((reqlen = request_check(hc->iqueue)) <= 2) return; -- 1.7.10.4