]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: fix thread naming
authorJohn Spray <john.spray@redhat.com>
Thu, 12 Oct 2017 17:14:02 +0000 (13:14 -0400)
committerJohn Spray <john.spray@redhat.com>
Wed, 1 Nov 2017 23:03:29 +0000 (23:03 +0000)
Was passing a reference to a local stringstream into
Thread::create, not realising that it was taking a char*
reference instead of a copy.  Result was garbage (or usually,
all threads having the name of the last one created)

Signed-off-by: John Spray <john.spray@redhat.com>
(cherry picked from commit bb4e71ed2ebdee1ac5e4b3eee390060e19fea0d8)

src/mgr/ActivePyModules.cc
src/mgr/StandbyPyModules.cc

index be25bbfc918b6054660a70b2f18ba0ab648f50d2..4eeb9667ba7610c47dc43b7537e54e91cec8a73d 100644 (file)
@@ -336,10 +336,11 @@ int ActivePyModules::start_one(std::string const &module_name,
   if (r != 0) {
     return r;
   } else {
-    std::ostringstream thread_name;
-    thread_name << "mgr." << module_name;
     dout(4) << "Starting thread for " << module_name << dendl;
-    modules[module_name]->thread.create(thread_name.str().c_str());
+    // Giving Thread the module's module_name member as its
+    // char* thread name: thread must not outlive module class lifetime.
+    modules[module_name]->thread.create(
+        modules[module_name]->get_name().c_str());
 
     return 0;
   }
index 3992553bd440891f685fe99004f24ab27a2d8416..2b442d5ef9d29f2056ec66088f50f921863df132 100644 (file)
@@ -97,10 +97,11 @@ int StandbyPyModules::start_one(std::string const &module_name,
     modules.erase(module_name);
     return r;
   } else {
-    std::ostringstream thread_name;
-    thread_name << "mgr." << module_name;
     dout(4) << "Starting thread for " << module_name << dendl;
-    modules[module_name]->thread.create(thread_name.str().c_str());
+    // Giving Thread the module's module_name member as its
+    // char* thread name: thread must not outlive module class lifetime.
+    modules[module_name]->thread.create(
+        modules[module_name]->get_name().c_str());
     return 0;
   }
 }