From bacd9172e78b2b68ec29bdde0b3bed56238f84a9 Mon Sep 17 00:00:00 2001 From: Patti Vacek Date: Tue, 29 Mar 2022 10:00:34 +0200 Subject: [PATCH] core: abort retrying when closing down. (#312) Signed-off-by: Patti Vacek --- src/internal/sio_client_impl.cpp | 7 +++++-- src/internal/sio_client_impl.h | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/internal/sio_client_impl.cpp b/src/internal/sio_client_impl.cpp index 5254020..6246a95 100644 --- a/src/internal/sio_client_impl.cpp +++ b/src/internal/sio_client_impl.cpp @@ -111,6 +111,7 @@ namespace sio m_auth = auth; this->reset_states(); + m_abort_retries = false; m_client.get_io_service().dispatch(std::bind(&client_impl::connect_impl,this,uri,m_query_string)); m_network_thread.reset(new thread(std::bind(&client_impl::run_loop,this)));//uri lifecycle? @@ -149,6 +150,7 @@ namespace sio void client_impl::close() { m_con_state = con_closing; + m_abort_retries = true; this->sockets_invoke_void(&sio::socket::close); m_client.get_io_service().dispatch(std::bind(&client_impl::close_impl, this,close::status::normal,"End by user")); } @@ -156,6 +158,7 @@ namespace sio void client_impl::sync_close() { m_con_state = con_closing; + m_abort_retries = true; this->sockets_invoke_void(&sio::socket::close); m_client.get_io_service().dispatch(std::bind(&client_impl::close_impl, this,close::status::normal,"End by user")); if(m_network_thread) @@ -375,7 +378,7 @@ namespace sio m_con_state = con_closed; this->sockets_invoke_void(&sio::socket::on_disconnect); LOG("Connection failed." << endl); - if(m_reconn_madenext_delay(); @@ -439,7 +442,7 @@ namespace sio else { this->sockets_invoke_void(&sio::socket::on_disconnect); - if(m_reconn_madenext_delay(); diff --git a/src/internal/sio_client_impl.h b/src/internal/sio_client_impl.h index bbc5ae6..8e35887 100644 --- a/src/internal/sio_client_impl.h +++ b/src/internal/sio_client_impl.h @@ -38,6 +38,7 @@ typedef websocketpp::config::asio_client client_config; #include #include +#include #include #include #include @@ -236,7 +237,9 @@ namespace sio unsigned m_reconn_attempts; unsigned m_reconn_made; - + + std::atomic m_abort_retries { false }; + friend class sio::client; friend class sio::socket; };