Merge pull request #69623 from sunyuechi/wip-iocache-reply-leak-teardown

tools/immutable_object_cache: don't leak in-flight replies on teardown

Reviewed-by: Kefu Chai <k.chai@proxmox.com>
Reviewed-by: Ilya Dryomov <idryomov@gmail.com>
This commit is contained in:
Ilya Dryomov 2026-07-15 21:35:21 +02:00 committed by GitHub
commit 6497e5ff17
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View 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;