X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/mLib/blobdiff_plain/1ef7279c324e278ecf75243ca651710db9ac708e..ee9b1404a97247490a09fcf10af83a76a3d3d72d:/selbuf.c diff --git a/selbuf.c b/selbuf.c index aafe711..b8b1161 100644 --- a/selbuf.c +++ b/selbuf.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: selbuf.c,v 1.2 1999/05/17 20:36:50 mdw Exp $ + * $Id: selbuf.c,v 1.3 1999/05/22 13:41:00 mdw Exp $ * * Line-buffering select handler * @@ -30,6 +30,9 @@ /*----- Revision history --------------------------------------------------* * * $Log: selbuf.c,v $ + * Revision 1.3 1999/05/22 13:41:00 mdw + * Fix end-of-file detection and error handling. + * * Revision 1.2 1999/05/17 20:36:50 mdw * Make the magical constants for the buffer flags uppercase. * @@ -111,23 +114,21 @@ static void selbuf_read(int fd, unsigned mode, void *vp) int n; sz = lbuf_free(&b->b, &p); -again: n = read(fd, p, sz); - if (n <= 0) { - switch (errno) { - case EINTR: - goto again; - case EAGAIN: + if (n == 0) + lbuf_close(&b->b); + else if (n > 0) + lbuf_flush(&b->b, p, n); + else switch (errno) { + case EINTR: + case EAGAIN: #if EAGAIN != EWOULDBLOCK - case EWOULDBLOCK: + case EWOULDBLOCK: #endif - return; - default: - lbuf_close(&b->b); - } + return; + default: + lbuf_close(&b->b); } - else - lbuf_flush(&b->b, p, n); } /* --- @selbuf_init@ --- *