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.
This commit is contained in:
parent
8b4f6f1778
commit
ab1e8305a1
|
@ -525,7 +525,7 @@ void session_impl::do_read() {
|
||||||
read_socket([this](const boost::system::error_code &ec,
|
read_socket([this](const boost::system::error_code &ec,
|
||||||
std::size_t bytes_transferred) {
|
std::size_t bytes_transferred) {
|
||||||
if (ec) {
|
if (ec) {
|
||||||
if (ec.value() == boost::asio::error::operation_aborted) {
|
if (!should_stop()) {
|
||||||
call_error_cb(ec);
|
call_error_cb(ec);
|
||||||
shutdown_socket();
|
shutdown_socket();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue