Browse Source

[5261] Eliminated valgrind errors in libkea-http.

Marcin Siodelski 8 years ago
parent
commit
07d85808c0
2 changed files with 6 additions and 1 deletions
  1. 5 1
      src/lib/http/connection.cc
  2. 1 0
      src/lib/http/connection_pool.cc

+ 5 - 1
src/lib/http/connection.cc

@@ -148,8 +148,12 @@ HttpConnection::acceptorCallback(const boost::system::error_code& ec) {
                   HTTP_REQUEST_RECEIVE_START)
                   HTTP_REQUEST_RECEIVE_START)
             .arg(getRemoteEndpointAddressAsText())
             .arg(getRemoteEndpointAddressAsText())
             .arg(static_cast<unsigned>(request_timeout_/1000));
             .arg(static_cast<unsigned>(request_timeout_/1000));
+        // Pass raw pointer rather than shared_ptr to this object,
+        // because IntervalTimer already passes shared pointer to the
+        // IntervalTimerImpl to make sure that the callback remains
+        // valid.
         request_timer_.setup(boost::bind(&HttpConnection::requestTimeoutCallback,
         request_timer_.setup(boost::bind(&HttpConnection::requestTimeoutCallback,
-                                         shared_from_this()),
+                                         this),
                              request_timeout_, IntervalTimer::ONE_SHOT);
                              request_timeout_, IntervalTimer::ONE_SHOT);
         doRead();
         doRead();
     }
     }

+ 1 - 0
src/lib/http/connection_pool.cc

@@ -19,6 +19,7 @@ HttpConnectionPool::start(const HttpConnectionPtr& connection) {
 void
 void
 HttpConnectionPool::stop(const HttpConnectionPtr& connection) {
 HttpConnectionPool::stop(const HttpConnectionPtr& connection) {
     connections_.remove(connection);
     connections_.remove(connection);
+    connection->close();
 }
 }
 
 
 void
 void