Please sign in to comment.
Fixes race condition in PooledConnection.shutdown()
Previously, if PooledConnection.shutdown() was called before the connection process had completed, _closeConnections would only call ConnectionInPool.close() on each connection in the pool if that ConnectionInPool had connected == true. If the connection process was still in-progress, connected would be set to false, close() would not be called, and the socket would later connect, causing tests to hang. This adds two events to ConnectionInPool, 'connected' and 'disconnected' - 'disconnected' is not actually needed, just added for symmetry. Instead of setting ConnectionInPool.connected directly, call setConnected() or setDisconnected() and the appropriate event will be emitted. ConnectionInPool.closeConnections now attaches an on('connected') handler to close the connection if the connection completes after shutdown() has been called.
- Loading branch information...
Showing with 33 additions and 2 deletions.