]> git.apps.os.sepia.ceph.com Git - ceph-ci.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 12:20:22 +0000 (08:20 -0400)
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>
src/mgr/ActivePyModules.cc
src/mgr/StandbyPyModules.cc

index e1cde4fd7d31d3dafd409b86a880779c565e695b..072f10d1c7955c89f117294a85aa9a81192ebe10 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;
   }
 }