From: Dan Mick Date: Tue, 11 Apr 2017 22:31:48 +0000 (-0700) Subject: ServeThread: add 'running' flag, don't notify non-running threads X-Git-Tag: v12.1.0~10^2~38^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f4bc4f64ad2d7a30d5e91c0ba4b75440a99464d0;p=ceph.git ServeThread: add 'running' flag, don't notify non-running threads Signed-off-by: Dan Mick --- diff --git a/src/mgr/PyModules.cc b/src/mgr/PyModules.cc index 3e00822fc280..10ac4adb8de3 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. //