]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5303] Use raw pointer to the timeout handler class in HTTP connections.
authorMarcin Siodelski <marcin@isc.org>
Thu, 1 Jun 2017 08:41:50 +0000 (10:41 +0200)
committerMarcin Siodelski <marcin@isc.org>
Thu, 1 Jun 2017 10:56:50 +0000 (12:56 +0200)
This prevents dangling timers after the connection has been terminated.

src/lib/http/connection.cc

index 6944bf2b37e59913b50e5b19f84e9b09ac21bb6b..9f33d9aeff2ca68b8b04ac29a9a0afd6836dda80 100644 (file)
@@ -148,8 +148,11 @@ HttpConnection::acceptorCallback(const boost::system::error_code& ec) {
                   HTTP_REQUEST_RECEIVE_START)
             .arg(getRemoteEndpointAddressAsText())
             .arg(static_cast<unsigned>(request_timeout_/1000));
+        // Use 'this' instead of shared_from_this() because the IntervalTimer
+        // class already submits shared pointer to IntervalTimerImpl to
+        // protect against premature class instance destruction.
         request_timer_.setup(boost::bind(&HttpConnection::requestTimeoutCallback,
-                                         shared_from_this()),
+                                         this),
                              request_timeout_, IntervalTimer::ONE_SHOT);
         doRead();
     }