Fix coupling error on Solaris
authorRyan Dahl <ry@tinyclouds.org>
Tue, 2 Mar 2010 20:39:28 +0000 (20:39 +0000)
committerRyan Dahl <ry@tinyclouds.org>
Tue, 2 Mar 2010 20:39:38 +0000 (20:39 +0000)
Was getting a lot of

  push_pump read(): Resource temporarily unavailable

Apparently Solaris can return read() < 0 but errno == 0 to indicate a
EAGAIN?

deps/coupling/coupling.c

index f6b03f3..ce29e24 100644 (file)
@@ -180,7 +180,7 @@ pull_pump (int pullfd, int pushfd)
       /* eof */
       close(pullfd);
       pullfd = -1;
-    } else if (r < 0 && errno != EINTR && errno != EAGAIN) {
+    } else if (r < 0 && errno && errno != EINTR && errno != EAGAIN) {
       /* error */
       perror("pull_pump read()");
       close(pullfd);
@@ -192,7 +192,7 @@ pull_pump (int pullfd, int pushfd)
       /* non-blocking write() to the pipe */
       r = ring_buffer_push(&ring, pushfd);
 
-      if (r < 0 && errno != EAGAIN && errno != EINTR) {
+      if (r < 0 && errno && errno != EAGAIN && errno != EINTR) {
         if (errno == EPIPE) {
           /* This happens if someone closes the other end of the pipe.  This
            * is a normal forced close of STDIN. Hopefully there wasn't data
@@ -274,7 +274,7 @@ push_pump (int pullfd, int pushfd)
       /* eof */
       close(pullfd);
       pullfd = -1;
-    } else if (r < 0 && errno != EINTR && errno != EAGAIN) {
+    } else if (r < 0 && errno && errno != EINTR && errno != EAGAIN) {
       perror("push_pump read()");
       close(pullfd);
       pullfd = -1;
@@ -288,14 +288,14 @@ push_pump (int pullfd, int pushfd)
 
       /* If there was a problem, just exit the entire function */
 
-      if (r < 0 && errno != EINTR) {
+      if (r < 0 && errno && errno != EINTR && errno != EAGAIN) {
         close(pushfd);
         close(pullfd);
         pushfd = pullfd = -1;
         return;
       }
     }
-    
+
     if (pullfd >= 0) {
       /* select for readability on the pullfd */
       r = select(pullfd+1, &readfds, NULL, &exceptfds, NULL);