From f4bc4f64ad2d7a30d5e91c0ba4b75440a99464d0 Mon Sep 17 00:00:00 2001 From: Dan Mick Date: Tue, 11 Apr 2017 15:31:48 -0700 Subject: [PATCH] ServeThread: add 'running' flag, don't notify non-running threads Signed-off-by: Dan Mick --- src/mgr/PyModules.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mgr/PyModules.cc b/src/mgr/PyModules.cc index 3e00822fc28..10ac4adb8de 100644 --- a/src/mgr/PyModules.cc +++ b/src/mgr/PyModules.cc @@ -424,6 +424,8 @@ class ServeThread : public Thread MgrPyModule *mod; public: + bool running; + ServeThread(MgrPyModule *mod_) : mod(mod_) {} @@ -431,12 +433,14 @@ public: { PyGILState_STATE gstate; gstate = PyGILState_Ensure(); + running = true; dout(4) << "Entering thread for " << mod->get_name() << dendl; mod->serve(); PyGILState_Release(gstate); + running = false; return nullptr; } }; @@ -499,6 +503,8 @@ void PyModules::notify_all(const std::string ¬ify_type, dout(10) << __func__ << ": notify_all " << notify_type << dendl; for (auto& i : modules) { auto module = i.second.get(); + if (!serve_threads[i.first]->running) + continue; // Send all python calls down a Finisher to avoid blocking // C++ code, and avoid any potential lock cycles. finisher.queue(new FunctionContext([module, notify_type, notify_id](int r){ @@ -514,6 +520,8 @@ void PyModules::notify_all(const LogEntry &log_entry) dout(10) << __func__ << ": notify_all (clog)" << dendl; for (auto& i : modules) { auto module = i.second.get(); + if (!serve_threads[i.first]->running) + continue; // Send all python calls down a Finisher to avoid blocking // C++ code, and avoid any potential lock cycles. // -- 2.47.3