summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2013-08-13 13:14:59 -0700
committerSage Weil <sage@inktank.com>2013-08-20 08:11:03 -0700
commit47c89497b7f69cbf1557cd05b89837c388e2ba2f (patch)
tree098da395a7dca9cfd94947c3669641bce6d5a3a2
parentb3a9a8c4e5edff5431d8da71033047eced6bf985 (diff)
downloadceph-47c89497b7f69cbf1557cd05b89837c388e2ba2f.tar.gz
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 <sage@inktank.com> Reviewed-by: Yehuda Sadeh <yehuda@inktank.com> (cherry picked from commit 6f5d8036f3e70c5e30edf7e36fb8ff9a56197f60)
-rw-r--r--src/librados/RadosClient.cc15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/librados/RadosClient.cc b/src/librados/RadosClient.cc
index 48b6a3cabf6..8a5f499ec15 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<uint64_t, WatchContext *>::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();
}