]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: handle long-named mgr modules
authorJohn Spray <john.spray@redhat.com>
Tue, 15 May 2018 14:40:00 +0000 (15:40 +0100)
committerJohn Spray <john.spray@redhat.com>
Fri, 6 Jul 2018 10:01:20 +0000 (11:01 +0100)
Signed-off-by: John Spray <john.spray@redhat.com>
src/mgr/ActivePyModules.cc
src/mgr/PyModuleRunner.h

index db74b41c9e87ac0e8d6e1143cd643f02ad243739..30bab738f0a344d6daea301bcf101196e708301b 100644 (file)
@@ -375,16 +375,14 @@ int ActivePyModules::start_one(PyModuleRef py_module)
   assert(modules.count(py_module->get_name()) == 0);
 
   modules[py_module->get_name()].reset(new ActivePyModule(py_module, clog));
+  auto active_module = modules.at(py_module->get_name()).get();
 
-  int r = modules[py_module->get_name()]->load(this);
+  int r = active_module->load(this);
   if (r != 0) {
     return r;
   } else {
     dout(4) << "Starting thread for " << py_module->get_name() << dendl;
-    // Giving Thread the module's module_name member as its
-    // char* thread name: thread must not outlive module class lifetime.
-    modules[py_module->get_name()]->thread.create(
-        py_module->get_name().c_str());
+    active_module->thread.create(active_module->get_thread_name());
 
     return 0;
   }
index 4b4a53bc97940812c5ac60bb7da68dbd85e0ffe9..c6bf18926fae2171408d14739c03ae26f1936825 100644 (file)
@@ -46,12 +46,18 @@ protected:
     void *entry() override;
   };
 
+  std::string thread_name;
 
 public:
   int serve();
   void shutdown();
   void log(int level, const std::string &record);
 
+  const char *get_thread_name() const
+  {
+    return thread_name.c_str();
+  }
+
   PyModuleRunner(
       const PyModuleRef &py_module_,
       LogChannelRef clog_)
@@ -60,6 +66,10 @@ public:
       clog(clog_),
       thread(this)
   {
+    // Shortened name for use as thread name, because thread names
+    // required to be <16 chars
+    thread_name = py_module->get_name().substr(0, 15);
+
     assert(py_module != nullptr);
   }