From c18da0482842e88ef81954ba8ae80128d1aad2ad Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sat, 17 May 2014 18:33:36 -0700 Subject: [PATCH] osd: fix narrow session refcount race The set_priv() call consumes a ref. Technically the local 's' is not actually owned by use by the time we get to the con_front set_priv(). Signed-off-by: Sage Weil --- src/osd/OSD.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 55c2be0b470..25366cc7157 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -2803,7 +2803,7 @@ void OSD::_add_heartbeat_peer(int p) hi->peer = p; HeartbeatSession *s = new HeartbeatSession(p); hi->con_back = cons.first.get(); - hi->con_back->set_priv(s); + hi->con_back->set_priv(s->get()); if (cons.second) { hi->con_front = cons.second.get(); hi->con_front->set_priv(s->get()); @@ -2817,6 +2817,7 @@ void OSD::_add_heartbeat_peer(int p) << " " << hi->con_back->get_peer_addr() << dendl; } + s->put(); } else { hi = &i->second; } -- 2.47.3