From: Marcin Siodelski Date: Thu, 1 Jun 2017 08:41:50 +0000 (+0200) Subject: [5303] Use raw pointer to the timeout handler class in HTTP connections. X-Git-Tag: trac5286_base~1^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4c48a72ce9b29356d98378e575cae6544afde5eb;p=thirdparty%2Fkea.git [5303] Use raw pointer to the timeout handler class in HTTP connections. This prevents dangling timers after the connection has been terminated. --- diff --git a/src/lib/http/connection.cc b/src/lib/http/connection.cc index 6944bf2b37..9f33d9aeff 100644 --- a/src/lib/http/connection.cc +++ b/src/lib/http/connection.cc @@ -148,8 +148,11 @@ HttpConnection::acceptorCallback(const boost::system::error_code& ec) { HTTP_REQUEST_RECEIVE_START) .arg(getRemoteEndpointAddressAsText()) .arg(static_cast(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(); }