Fix SSLSocketInitiator fd leak and CPU spin on connection failure (#713)
Three related bugs caused file descriptor leaks and busy-spinning when the SSL initiator cannot connect (e.g. dead port): 1. ssl_socket_close() skipped socket_close() when an SSL object was present, relying on SSL_free() to close the fd. But the BIO is created with BIO_NOCLOSE in SSLSocketInitiator::doConnect, so SSL_free() never closes the underlying fd. Add socket_close() after the SSL_shutdown loop so the fd is always released. 2. ConnectorWrapper::onError() (connection-refused / POLLERR path) did not drop the socket from the monitor before notifying the strategy. On each subsequent block() call poll() returned POLLERR again, spinning the CPU. Add monitor.drop(socket) first, matching the pattern in ServerWrapper::onError. 3. handshakeSSLAndHandleConnection() deleted the SSLSocketConnection on SSL handshake failure without first calling disconnect(), leaving the socket in the monitor's read set. Call pSocketConnection->disconnect() before pSession->disconnect() so the specific failing socket is removed from the monitor immediately. Fixes #682.
O
Oren Miller committed
63deeff99d4b016ee4d3c67fba6664646cd3233b
Parent: 3a76317
Committed by GitHub <noreply@github.com>
on 5/9/2026, 5:36:21 PM