From: John Spray Date: Tue, 15 May 2018 14:40:00 +0000 (+0100) Subject: mgr: handle long-named mgr modules X-Git-Tag: v14.0.1~916^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=13bcddea23f834c520d86050d03a8fc2e8a21a6a;p=ceph-ci.git mgr: handle long-named mgr modules Signed-off-by: John Spray --- diff --git a/src/mgr/ActivePyModules.cc b/src/mgr/ActivePyModules.cc index db74b41c9e8..30bab738f0a 100644 --- a/src/mgr/ActivePyModules.cc +++ b/src/mgr/ActivePyModules.cc @@ -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; } diff --git a/src/mgr/PyModuleRunner.h b/src/mgr/PyModuleRunner.h index 4b4a53bc979..c6bf18926fa 100644 --- a/src/mgr/PyModuleRunner.h +++ b/src/mgr/PyModuleRunner.h @@ -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); }