]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: svc_notify: call set_enabled() when registering callback
authorYehuda Sadeh <yehuda@redhat.com>
Tue, 6 Nov 2018 00:05:14 +0000 (16:05 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 8 Nov 2018 17:19:30 +0000 (09:19 -0800)
svc_notify starts before svc_sysobj_cache, this way we make sure
svc_sysobj_cache gets the status callback triggered.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/services/svc_notify.cc
src/rgw/services/svc_notify.h

index 938b417c85fafaee92b279788bc33e6ec58ced53..2cbbdcb66eab19b8ad47af489574570bfd20da98 100644 (file)
@@ -337,12 +337,13 @@ int RGWSI_Notify::watch_cb(uint64_t notify_id,
 
 void RGWSI_Notify::set_enabled(bool status)
 {
-  RWLock::RLocker l(watchers_lock);
+  RWLock::WLocker l(watchers_lock);
   _set_enabled(status);
 }
 
 void RGWSI_Notify::_set_enabled(bool status)
 {
+  enabled = status;
   if (cb) {
     cb->set_enabled(status);
   }
@@ -459,6 +460,7 @@ void RGWSI_Notify::register_watch_cb(CB *_cb)
 {
   RWLock::WLocker l(watchers_lock);
   cb = _cb;
+  _set_enabled(enabled);
 }
 
 void RGWSI_Notify::schedule_context(Context *c)
index 3dfbfd3e4ee2e5210200b50231c2cc33dab1924a..ca72c59e9ea642906d6c2d58b2c440813a69d459 100644 (file)
@@ -35,6 +35,8 @@ private:
   std::set<int> watchers_set;
   vector<RGWSI_RADOS::Obj> notify_objs;
 
+  bool enabled{false};
+
   double inject_notify_timeout_probability{0};
   unsigned max_notify_retries{0};