Skip to content

Commit 7e6f561

Browse files
authored
Merge pull request socketio#2 from ErisExchange/eris-more_reliable_close
Consider all client-initiated closes to be close_reason_normal.
2 parents 23ed46b + 29468bf commit 7e6f561

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/internal/sio_client_impl.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ namespace sio
411411
void client_impl::on_close(connection_hdl con)
412412
{
413413
LOG("Client Disconnected." << endl);
414+
con_state m_con_state_was = m_con_state;
414415
m_con_state = con_closed;
415416
lib::error_code ec;
416417
close::status::value code = close::status::normal;
@@ -426,7 +427,11 @@ namespace sio
426427
m_con.reset();
427428
this->clear_timers();
428429
client::close_reason reason;
429-
if(code == close::status::normal)
430+
431+
// If we initiated the close, no matter what the close status was,
432+
// we'll consider it a normal close. (When using TLS, we can
433+
// sometimes get a TLS Short Read error when closing.)
434+
if(code == close::status::normal || m_con_state_was == con_closing)
430435
{
431436
this->sockets_invoke_void(&sio::socket::on_disconnect);
432437
reason = client::close_reason_normal;

0 commit comments

Comments
 (0)