Forráskód Böngészése

HPCC-17088 Force shutdown() in cancel_accept if not in accept state

If a socket is used to wait on data (wait_read) then accept(),
the chances are a cancel_accept() call on another thread will not
catch the socket in accept state.
Closing the socket, does not cause wait_read/poll to notice.
shutdown() does.

This was noticed in dafilesrv when it receives a stop command.
The consequence of the wait_read not noticing the close() was
that dafilesrv did not stop until the wait_read timeout (60s)
had expired.

Signed-off-by: Jake Smith <jake.smith@lexisnexisrisk.com>
Jake Smith 8 éve
szülő
commit
99587fe90e
1 módosított fájl, 2 hozzáadás és 1 törlés
  1. 2 1
      system/jlib/jsocket.cpp

+ 2 - 1
system/jlib/jsocket.cpp

@@ -399,7 +399,7 @@ public:
     void        close();
     void        errclose();
     bool        connectionless() { return (sockmode!=sm_tcp)&&(sockmode!=sm_tcp_server); }
-    void        shutdown(unsigned mode);
+    void        shutdown(unsigned mode=SHUTDOWN_READWRITE);
 
     ISocket*    accept(bool allowcancel);
     int         wait_read(unsigned timeout);
@@ -1164,6 +1164,7 @@ void CSocket::cancel_accept()
 #endif
     if (!in_accept) {
         accept_cancel_state = accept_cancelled;
+        shutdown();
         errclose();
         return;
     }