From 70b16d5b012dfb5b5493e23a91999c4ff23fdf1c Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 22 Sep 2020 17:03:17 +0800 Subject: [PATCH] crimson/osd: do not add ref when constructing MessageRef crimson::osd::PG::send_cluster_message() accepts a `Message*` pointer, and then hand it over to `shard_services.send_to_osd()`, which expects a `Ref`. so the raw pointer is used to construct an `intrusive_ptr`, which increment the refcount of that Message instance by one. but that Message was owned by nobody before that, so we end up with an `intrusive_ptr` of 2 refcount, and only a single owner. hence the memory leak. in this change, instructs the constructor to not add the refcount. Signed-off-by: Kefu Chai --- src/crimson/osd/pg.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crimson/osd/pg.h b/src/crimson/osd/pg.h index d754d18e8c754..3b193697ae45d 100644 --- a/src/crimson/osd/pg.h +++ b/src/crimson/osd/pg.h @@ -159,7 +159,7 @@ public: void send_cluster_message( int osd, Message *m, epoch_t epoch, bool share_map_update=false) final { - (void)shard_services.send_to_osd(osd, m, epoch); + (void)shard_services.send_to_osd(osd, MessageRef{m, false}, epoch); } void send_pg_created(pg_t pgid) final { -- 2.39.5