From: Sage Weil Date: Tue, 13 Aug 2013 20:14:59 +0000 (-0700) Subject: librados: fix MWatchNotify leak X-Git-Tag: v0.68~85 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6f5d8036f3e70c5e30edf7e36fb8ff9a56197f60;p=ceph.git librados: fix MWatchNotify leak Do not leak the message if the watcher is not registered. Also, simplify this block. Fixes (part of): #5949 Backport: dumpling, cuttlefish Signed-off-by: Sage Weil Reviewed-by: Yehuda Sadeh --- diff --git a/src/librados/RadosClient.cc b/src/librados/RadosClient.cc index 48b6a3cabf60..8a5f499ec152 100644 --- a/src/librados/RadosClient.cc +++ b/src/librados/RadosClient.cc @@ -563,16 +563,13 @@ public: void librados::RadosClient::watch_notify(MWatchNotify *m) { assert(lock.is_locked()); - WatchContext *wc = NULL; map::iterator iter = watchers.find(m->cookie); - if (iter != watchers.end()) - wc = iter->second; - - if (!wc) - return; - - wc->get(); - finisher.queue(new C_WatchNotify(wc, &lock, m->opcode, m->ver, m->notify_id, m->bl)); + if (iter != watchers.end()) { + WatchContext *wc = iter->second; + assert(wc); + wc->get(); + finisher.queue(new C_WatchNotify(wc, &lock, m->opcode, m->ver, m->notify_id, m->bl)); + } m->put(); }