From 9898c2e6653622da929bea54a718cd848bcaae05 Mon Sep 17 00:00:00 2001 From: Guenter Bartsch Date: Thu, 25 Oct 2001 15:48:03 +0000 Subject: ...hope I'm getting closer to a correct socket read return value interpretation... CVS patchset: 885 CVS date: 2001/10/25 15:48:03 --- src/input/input_http.c | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/input/input_http.c b/src/input/input_http.c index b6449b6ec..f755b4060 100644 --- a/src/input/input_http.c +++ b/src/input/input_http.c @@ -164,11 +164,16 @@ static int http_plugin_open (input_plugin_t *this_gen, char *mrl) { printf ("input_http: read...\n"); */ - switch (read (this->fh, &this->buf[len], 1)) { - case -1: - return 0; - case 0: - continue; + if (read (this->fh, &this->buf[len], 1) <=0) { + + switch (errno) { + case EAGAIN: + printf ("input_http: EAGAIN\n"); + continue; + default: + printf ("input_http: read error\n"); + return 0; + } } if (this->buf[len] == '\n') { @@ -197,15 +202,21 @@ static off_t http_plugin_read (input_plugin_t *this_gen, while (num_bytes < nlen) { - n = read (this->fh, buf, nlen); - - if (n<0) { - printf ("input_http: read error (%s)\n", strerror (errno)); - return num_bytes; - } else if (n > 0) { - num_bytes += n; - this->curpos += n; + n = read (this->fh, &buf[num_bytes], nlen - num_bytes); + + if (n <= 0) { + + switch (errno) { + case EAGAIN: + printf ("input_http: EAGAIN\n"); + continue; + default: + printf ("input_http: read error\n"); + return 0; + } } + + num_bytes += n; } return num_bytes; } -- cgit v1.2.3