From 7b785cf552b69163c8e3ccc2dd3e05176d88e18b Mon Sep 17 00:00:00 2001 From: Florent Le Coz Date: Sun, 22 Jun 2014 23:56:51 +0200 Subject: Delete the timeout event using the correct socket number, instead of -1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Was causing the event to not be removed in case of connection failure, which lead to a dangling timed event named “timeout-1”, which was called later, by some other SocketHandler for which even the socket creation failed (so, its socket is -1), with a pointer to the previous SocketHandler which has disappeared for a long time: segmentation fault etc. --- src/network/socket_handler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/network/socket_handler.cpp b/src/network/socket_handler.cpp index 43a63f0..52297e4 100644 --- a/src/network/socket_handler.cpp +++ b/src/network/socket_handler.cpp @@ -276,6 +276,8 @@ void SocketHandler::on_send() void SocketHandler::close() { + TimedEventsManager::instance().cancel("connection_timeout"s + + std::to_string(this->socket)); if (this->connected || this->connecting) this->poller->remove_socket_handler(this->get_socket()); if (this->socket != -1) @@ -288,8 +290,6 @@ void SocketHandler::close() this->in_buf.clear(); this->out_buf.clear(); this->port.clear(); - TimedEventsManager::instance().cancel("connection_timeout"s + - std::to_string(this->socket)); } socket_t SocketHandler::get_socket() const -- cgit v1.2.3