From: Marcin Siodelski Date: Mon, 26 Mar 2018 12:15:35 +0000 (+0200) Subject: [5470] Guard HTTP client against asyncSend and asyncReceive exceptions. X-Git-Tag: trac5458a_base~32^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=525c9d3c5e3e9d03702b54d81364454c1570a357;p=thirdparty%2Fkea.git [5470] Guard HTTP client against asyncSend and asyncReceive exceptions. --- diff --git a/src/lib/http/client.cc b/src/lib/http/client.cc index 7ec5dd53d1..2bb79f37f7 100644 --- a/src/lib/http/client.cc +++ b/src/lib/http/client.cc @@ -515,7 +515,12 @@ void Connection::doSend() { SocketCallback socket_cb(boost::bind(&Connection::sendCallback, shared_from_this(), _1, _2)); - socket_.asyncSend(&buf_[0], buf_.size(), socket_cb); + try { + socket_.asyncSend(&buf_[0], buf_.size(), socket_cb); + + } catch (const std::exception& ex) { + terminate(boost::asio::error::not_connected); + } } void @@ -523,8 +528,13 @@ Connection::doReceive() { TCPEndpoint endpoint; SocketCallback socket_cb(boost::bind(&Connection::receiveCallback, shared_from_this(), _1, _2)); - socket_.asyncReceive(static_cast(input_buf_.data()), input_buf_.size(), 0, - &endpoint, socket_cb); + + try { + socket_.asyncReceive(static_cast(input_buf_.data()), input_buf_.size(), 0, + &endpoint, socket_cb); + } catch (const std::exception& ex) { + terminate(boost::asio::error::not_connected); + } } void