Skip to content

Commit d1c73b7

Browse files
AdrianDCdarrachequesne
authored andcommitted
fix: resolve #254: handle closing sockets upon on_fail events
1 parent b196fa7 commit d1c73b7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/internal/sio_client_impl.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,12 @@ namespace sio
382382

383383
void client_impl::on_fail(connection_hdl)
384384
{
385+
if (m_con_state == con_closing) {
386+
LOG("Connection failed while closing." << endl);
387+
this->close();
388+
return;
389+
}
390+
385391
m_con.reset();
386392
m_con_state = con_closed;
387393
this->sockets_invoke_void(&sio::socket::on_disconnect);
@@ -404,6 +410,12 @@ namespace sio
404410

405411
void client_impl::on_open(connection_hdl con)
406412
{
413+
if (m_con_state == con_closing) {
414+
LOG("Connection opened while closing." << endl);
415+
this->close();
416+
return;
417+
}
418+
407419
LOG("Connected." << endl);
408420
m_con_state = con_opened;
409421
m_con = con;

0 commit comments

Comments
 (0)