From 2d6211c45552252864f7afa71d7634cbf1e2f9d0 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Fri, 4 Mar 2016 22:43:36 +0900 Subject: [PATCH] asio: Fix bug that server event loop breaks with exception This can happen when we call throwing version of basic_stream_socket::remote_endpoint() call while client disconnected. --- src/asio_server_connection.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/asio_server_connection.h b/src/asio_server_connection.h index 4498497d..6be79406 100644 --- a/src/asio_server_connection.h +++ b/src/asio_server_connection.h @@ -79,8 +79,10 @@ public: /// Start the first asynchronous operation for the connection. void start() { + boost::system::error_code ec; + handler_ = std::make_shared( - socket_.get_io_service(), socket_.lowest_layer().remote_endpoint(), + socket_.get_io_service(), socket_.lowest_layer().remote_endpoint(ec), [this]() { do_write(); }, mux_); if (handler_->start() != 0) { stop();