From a17a27dd5c14852f3b998a4040657861ef2eccd6 Mon Sep 17 00:00:00 2001 From: Peter Thorson Date: Mon, 24 Sep 2012 07:41:10 -0500 Subject: [PATCH] updates set_handler to by synchronous fixes #139 --- src/connection.hpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/connection.hpp b/src/connection.hpp index 8cf23db6cf..76fa0cea19 100644 --- a/src/connection.hpp +++ b/src/connection.hpp @@ -617,13 +617,21 @@ public: return; } - m_endpoint.endpoint_base::m_io_service.post( + // io_service::strand ordering guarantees are not sufficient here to + // make sure that this code is run before any messages are processed. + handler_ptr old_handler = m_handler; + + old_handler->on_unload(type::shared_from_this(),new_handler); + m_handler = new_handler; + new_handler->on_load(type::shared_from_this(),old_handler); + + /*m_endpoint.endpoint_base::m_io_service.post( m_strand.wrap(boost::bind( &type::set_handler_internal, type::shared_from_this(), new_handler )) - ); + );*/ } /// Set connection read threshold