]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/immutable_object_cache: don't leak in-flight replies on teardown 69623/head
authorSun Yuechi <sunyuechi@iscas.ac.cn>
Sun, 21 Jun 2026 08:42:54 +0000 (16:42 +0800)
committerSun Yuechi <sunyuechi@iscas.ac.cn>
Sun, 5 Jul 2026 11:34:45 +0000 (04:34 -0700)
CacheSession::send() deleted the reply in the async_write completion
handler. On teardown asio drops the pending handler without running it,
leaking the reply. Delete it right after encoding into bl instead; bl
owns the payload, so the write is unaffected.

Fixes: https://tracker.ceph.com/issues/77552
Signed-off-by: Sun Yuechi <sunyuechi@iscas.ac.cn>
src/tools/immutable_object_cache/CacheSession.cc

index e6adaead161ff4dabe9819d631a274e15863ce00..52f955142d3c9e6e95b48b9fdeb6f92e692d306c 100644 (file)
@@ -122,13 +122,15 @@ void CacheSession::send(ObjectCacheRequest* reply) {
   bufferlist bl;
   reply->encode();
   bl.append(reply->get_payload_bufferlist());
+  // bl owns the encoded payload; free reply here so it can't leak if the
+  // handler is dropped on teardown.
+  delete reply;
 
   boost::asio::async_write(m_dm_socket,
         boost::asio::buffer(bl.c_str(), bl.length()),
         boost::asio::transfer_exactly(bl.length()),
-        [this, bl, reply](const boost::system::error_code& err,
+        [this, bl](const boost::system::error_code& err,
           size_t bytes_transferred) {
-          delete reply;
           if (err || bytes_transferred != bl.length()) {
             fault(err);
             return;