Skip to content

Commit

Permalink
fix: resolve #254: handle closing sockets upon on_fail events
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianDC authored and darrachequesne committed Feb 8, 2021
1 parent b196fa7 commit d1c73b7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/internal/sio_client_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,12 @@ namespace sio

void client_impl::on_fail(connection_hdl)
{
if (m_con_state == con_closing) {
LOG("Connection failed while closing." << endl);
this->close();
return;
}

m_con.reset();
m_con_state = con_closed;
this->sockets_invoke_void(&sio::socket::on_disconnect);
Expand All @@ -404,6 +410,12 @@ namespace sio

void client_impl::on_open(connection_hdl con)
{
if (m_con_state == con_closing) {
LOG("Connection opened while closing." << endl);
this->close();
return;
}

LOG("Connected." << endl);
m_con_state = con_opened;
m_con = con;
Expand Down

0 comments on commit d1c73b7

Please sign in to comment.