From 2485efc26d68b6848cda02d66b54dd58769fcbd8 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Tue, 26 Jul 2016 12:50:13 -0400 Subject: [PATCH] rgw: clear realm watch on failed watch_restart if the realm is deleted while the gateway has a watch, it's disconnected and watch_restart() will fail. this results in a watch handle of 0, which leads to a segfault on ~RGWRealmWatcher when we pass it to unwatch() this commit cleans up the watch when watch_restart() fails, so we don't try to unwatch() on destruction Fixes: http://tracker.ceph.com/issues/16817 Signed-off-by: Casey Bodley (cherry picked from commit e5b8b5b27502fdacdac38effd7a55fd719911e85) --- src/rgw/rgw_realm_watcher.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_realm_watcher.cc b/src/rgw/rgw_realm_watcher.cc index d9383d6d31b5f..0ed332c8655c5 100644 --- a/src/rgw/rgw_realm_watcher.cc +++ b/src/rgw/rgw_realm_watcher.cc @@ -130,9 +130,12 @@ int RGWRealmWatcher::watch_restart() << " with " << cpp_strerror(-r) << dendl; } r = pool_ctx.watch2(watch_oid, &watch_handle, this); - if (r < 0) + if (r < 0) { lderr(cct) << "Failed to restart watch on " << watch_oid << " with " << cpp_strerror(-r) << dendl; + pool_ctx.close(); + watch_oid.clear(); + } return r; }