Commit 7b785cf5 authored by louiz’'s avatar louiz’

Delete the timeout event using the correct socket number, instead of -1

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.
parent 545ab11f
...@@ -276,6 +276,8 @@ void SocketHandler::on_send() ...@@ -276,6 +276,8 @@ void SocketHandler::on_send()
void SocketHandler::close() void SocketHandler::close()
{ {
TimedEventsManager::instance().cancel("connection_timeout"s +
if (this->connected || this->connecting) if (this->connected || this->connecting)
this->poller->remove_socket_handler(this->get_socket()); this->poller->remove_socket_handler(this->get_socket());
if (this->socket != -1) if (this->socket != -1)
...@@ -288,8 +290,6 @@ void SocketHandler::close() ...@@ -288,8 +290,6 @@ void SocketHandler::close()
this->in_buf.clear(); this->in_buf.clear();
this->out_buf.clear(); this->out_buf.clear();
this->port.clear(); this->port.clear();
TimedEventsManager::instance().cancel("connection_timeout"s +
} }
socket_t SocketHandler::get_socket() const socket_t SocketHandler::get_socket() const
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment