]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix uninitialized access 25002/head
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 8 Nov 2018 22:03:43 +0000 (14:03 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 8 Nov 2018 22:03:43 +0000 (14:03 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/services/svc_finisher.h
src/rgw/services/svc_notify.cc
src/rgw/services/svc_notify.h

index c1ae589e9dc1eea8ac762044a45e007fc0a18f06..116fd8fded07d87ddd5f1c9acd51e9be9ac9567d 100644 (file)
@@ -20,7 +20,7 @@ private:
   void shutdown() override;
 
   std::map<int, ShutdownCB *> shutdown_cbs;
-  std::atomic<int> handles_counter;
+  std::atomic<int> handles_counter{0};
 
 protected:
   void init() {}
index 2cbbdcb66eab19b8ad47af489574570bfd20da98..466b9d0696d1d999f2defefa0ebdc316af3f93bb 100644 (file)
@@ -260,7 +260,9 @@ int RGWSI_Notify::do_start()
   }
 
   shutdown_cb = new RGWSI_Notify_ShutdownCB(this);
-  finisher_svc->register_caller(shutdown_cb, &finisher_handle);
+  int handle;
+  finisher_svc->register_caller(shutdown_cb, &handle);
+  finisher_handle = handle;
 
   return 0;
 }
@@ -271,7 +273,9 @@ void RGWSI_Notify::shutdown()
     return;
   }
 
-  finisher_svc->unregister_caller(finisher_handle);
+  if (finisher_handle) {
+    finisher_svc->unregister_caller(*finisher_handle);
+  }
   finalize_watch();
 
   delete shutdown_cb;
index ca72c59e9ea642906d6c2d58b2c440813a69d459..cd9d9eb89d973f3cc579ad7883a1eff71f332974 100644 (file)
@@ -45,7 +45,7 @@ private:
 
   CB *cb{nullptr};
 
-  int finisher_handle{0};
+  std::optional<int> finisher_handle;
   RGWSI_Notify_ShutdownCB *shutdown_cb{nullptr};
 
   bool finalized{false};