]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5470] Guard HTTP client against asyncSend and asyncReceive exceptions.
authorMarcin Siodelski <marcin@isc.org>
Mon, 26 Mar 2018 12:15:35 +0000 (14:15 +0200)
committerMarcin Siodelski <marcin@isc.org>
Mon, 26 Mar 2018 12:15:35 +0000 (14:15 +0200)
src/lib/http/client.cc

index 7ec5dd53d10c3ac6843bf0a18bf025eab2f03f0a..2bb79f37f7403522f345bab56a779a66c8657947 100644 (file)
@@ -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<void*>(input_buf_.data()), input_buf_.size(), 0,
-                         &endpoint, socket_cb);
+
+    try {
+        socket_.asyncReceive(static_cast<void*>(input_buf_.data()), input_buf_.size(), 0,
+                             &endpoint, socket_cb);
+    } catch (const std::exception& ex) {
+        terminate(boost::asio::error::not_connected);
+    }
 }
 
 void