From ad2932bbff7dc666bf9e892566db296e1f4d31e4 Mon Sep 17 00:00:00 2001 From: Peter Thorson Date: Thu, 24 Jul 2014 21:39:09 -0500 Subject: [PATCH] Disable open timeout when duration is set to zero --- websocketpp/transport/asio/connection.hpp | 29 +++++++++++++---------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/websocketpp/transport/asio/connection.hpp b/websocketpp/transport/asio/connection.hpp index cd78fd2444..fa17b78278 100644 --- a/websocketpp/transport/asio/connection.hpp +++ b/websocketpp/transport/asio/connection.hpp @@ -477,16 +477,19 @@ protected: } timer_ptr post_timer; - post_timer = set_timer( - config::timeout_socket_post_init, - lib::bind( - &type::handle_post_init_timeout, - get_shared(), - post_timer, - m_init_handler, - lib::placeholders::_1 - ) - ); + + if (config::timeout_socket_post_init > 0) { + post_timer = set_timer( + config::timeout_socket_post_init, + lib::bind( + &type::handle_post_init_timeout, + get_shared(), + post_timer, + m_init_handler, + lib::placeholders::_1 + ) + ); + } socket_con_type::post_init( lib::bind( @@ -530,13 +533,15 @@ protected: lib::error_code const & ec) { if (ec == transport::error::operation_aborted || - post_timer->expires_from_now().is_negative()) + (post_timer && post_timer->expires_from_now().is_negative())) { m_alog.write(log::alevel::devel,"post_init cancelled"); return; } - post_timer->cancel(); + if (post_timer) { + post_timer->cancel(); + } if (m_alog.static_test(log::alevel::devel)) { m_alog.write(log::alevel::devel,"asio connection handle_post_init");