From ab1e8305a1dc967439acaaf3f6cbd02244464bc0 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Thu, 19 Nov 2015 00:00:05 +0900 Subject: [PATCH] asio: client: call on_error when connection is dropped When connection is dropped, we get "nonzero" error code ec in read_socket callback. We can just call on_error callback if ec is nonzero. But there is a problem when we did ordered shutdown. In this case, we also get EOF in ec, but we don't want to call on_error because it is not an error. To workaround this, we check return value of should_stop(). If it is true, then we assume that HTTP/2 session cleanly ended, and we don't call on_error. --- src/asio_client_session_impl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/asio_client_session_impl.cc b/src/asio_client_session_impl.cc index d3a57a1e..33f21137 100644 --- a/src/asio_client_session_impl.cc +++ b/src/asio_client_session_impl.cc @@ -525,7 +525,7 @@ void session_impl::do_read() { read_socket([this](const boost::system::error_code &ec, std::size_t bytes_transferred) { if (ec) { - if (ec.value() == boost::asio::error::operation_aborted) { + if (!should_stop()) { call_error_cb(ec); shutdown_socket(); }