]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: take a lock within PyModuleRegistry's mutators and accessor 50963/head
authorRamana Raja <rraja@redhat.com>
Wed, 15 Feb 2023 18:41:00 +0000 (13:41 -0500)
committerRamana Raja <rraja@redhat.com>
Fri, 21 Apr 2023 18:42:05 +0000 (14:42 -0400)
... that modify and access the data member 'clients' respectively.

Signed-off-by: Ramana Raja <rraja@redhat.com>
(cherry picked from commit a586dcc57ab35a269f0c271756951d49f422662d)

src/mgr/ActivePyModules.cc
src/mgr/PyModuleRegistry.h

index 02226270beb57bf9bb65b82945f066762f69df24..8359a8369638077ca52f68a7621b49dd4db77d4b 100644 (file)
@@ -1500,8 +1500,6 @@ void ActivePyModules::cluster_log(const std::string &channel, clog_type prio,
 
 void ActivePyModules::register_client(std::string_view name, std::string addrs)
 {
-  std::lock_guard l(lock);
-
   entity_addrvec_t addrv;
   addrv.parse(addrs.data());
 
@@ -1511,8 +1509,6 @@ void ActivePyModules::register_client(std::string_view name, std::string addrs)
 
 void ActivePyModules::unregister_client(std::string_view name, std::string addrs)
 {
-  std::lock_guard l(lock);
-
   entity_addrvec_t addrv;
   addrv.parse(addrs.data());
 
index 3231d7c667940266ecf88a2936f659392bde31e3..14b8339665a4276e4693bf344b4ea3236b8f3171 100644 (file)
@@ -204,10 +204,12 @@ public:
 
   void register_client(std::string_view name, entity_addrvec_t addrs)
   {
+    std::lock_guard l(lock);
     clients.emplace(std::string(name), std::move(addrs));
   }
   void unregister_client(std::string_view name, const entity_addrvec_t& addrs)
   {
+    std::lock_guard l(lock);
     auto itp = clients.equal_range(std::string(name));
     for (auto it = itp.first; it != itp.second; ++it) {
       if (it->second == addrs) {
@@ -219,6 +221,7 @@ public:
 
   auto get_clients() const
   {
+    std::lock_guard l(lock);
     return clients;
   }