Selaa lähdekoodia

Merge pull request #10816 from mckellyln/hpcc-18193

HPCC-18193 Return fail on wait_read POLLHUP event

Reviewed-By: Jake Smith <jake.smith@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 7 vuotta sitten
vanhempi
commit
041aad9386
1 muutettua tiedostoa jossa 10 lisäystä ja 0 poistoa
  1. 10 0
      system/jlib/jsocket.cpp

+ 10 - 0
system/jlib/jsocket.cpp

@@ -1624,6 +1624,16 @@ int CSocket::wait_read(unsigned timeout)
                 errno = logPollError(fds[0].revents, "wait_read");
                 ret = -1;
             }
+            else if (fds[0].revents & POLLHUP)
+            {
+                // with poll() we can now differentiate this event from select()
+                // used to be that this fell thru ok and recv() would return 0
+                // indicating the socket has been closed, but the errno in that
+                // case could be misleading (ETIMEDOUT etc.)
+                LOGERR2(998,5,"wait_read POLLHUP");
+                errno = ENOTCONN;
+                ret = -1;
+            }
             else
             {
                 // POLLIN | POLLHUP ok