From ac18d0ce4975793b6f7ff7dee44a07735995bfe9 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Wed, 7 Oct 2015 12:08:02 -0400 Subject: [PATCH] rgw: keep Context for reconfig timer cancellation Signed-off-by: Casey Bodley --- src/rgw/rgw_realm_watcher.cc | 12 ++++++------ src/rgw/rgw_realm_watcher.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/rgw/rgw_realm_watcher.cc b/src/rgw/rgw_realm_watcher.cc index 607fb8551e363..3878a5c4401fa 100644 --- a/src/rgw/rgw_realm_watcher.cc +++ b/src/rgw/rgw_realm_watcher.cc @@ -32,7 +32,7 @@ RGWRealmWatcher::RGWRealmWatcher(CephContext *cct, RGWRados *&store, frontends(frontends), timer(cct, mutex, USE_SAFE_TIMER_CALLBACKS), mutex("RGWRealmWatcher"), - reconfigure_scheduled(false) + reconfigure_scheduled(nullptr) { // no default realm, nothing to watch if (store->realm.get_id().empty()) { @@ -74,7 +74,7 @@ void RGWRealmWatcher::reconfigure() // allow a new notify to reschedule us. it's important that we do this // before we start loading the new realm, or we could miss some updates Mutex::Locker lock(mutex); - reconfigure_scheduled = false; + reconfigure_scheduled = nullptr; } while (!store) { @@ -106,8 +106,8 @@ void RGWRealmWatcher::reconfigure() if (reconfigure_scheduled) { // cancel the event; we'll handle it now - reconfigure_scheduled = false; - timer.cancel_all_events(); + timer.cancel_event(reconfigure_scheduled); + reconfigure_scheduled = nullptr; // if we successfully created a store, clean it up outside of the lock, // then continue to loop and recreate another @@ -159,12 +159,12 @@ void RGWRealmWatcher::handle_notify(uint64_t notify_id, uint64_t cookie, return; } - reconfigure_scheduled = true; + reconfigure_scheduled = new C_Reconfigure(this); cond.SignalOne(); // wake reconfigure() if it blocked on a bad configuration // schedule reconfigure() with a delay so we can batch up changes auto delay = cct->_conf->rgw_realm_reconfigure_delay; - timer.add_event_after(delay, new C_Reconfigure(this)); + timer.add_event_after(delay, reconfigure_scheduled); ldout(cct, 4) << "Notification on " << watch_oid << ", reconfiguration " "scheduled in " << delay << 's' << dendl; diff --git a/src/rgw/rgw_realm_watcher.h b/src/rgw/rgw_realm_watcher.h index d8e3935209b5a..61b508a2a0e68 100644 --- a/src/rgw/rgw_realm_watcher.h +++ b/src/rgw/rgw_realm_watcher.h @@ -71,7 +71,7 @@ class RGWRealmWatcher : public librados::WatchCtx2 { SafeTimer timer; Mutex mutex; //< protects access to timer and reconfigure_scheduled Cond cond; //< to signal reconfigure() after an invalid realm config - bool reconfigure_scheduled; //< true if reconfigure() is scheduled in timer + Context *reconfigure_scheduled; //< reconfigure() context if scheduled /// pause frontends and replace the RGWRados void reconfigure(); -- 2.39.5