chiark / gitweb /
Version bump.
[mLib] / selbuf.c
index aafe711f59dbec1ad86b9078b606a3b9aa4b31fc..b8b11611c69c7ec8e6e7452fd20cbe1ce5a67b0a 100644 (file)
--- 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@ --- *