From 9c305b7c09c32b8498a00780c8f642b6bbb0b526 Mon Sep 17 00:00:00 2001 From: John Spray Date: Wed, 14 Nov 2018 06:19:14 -0500 Subject: [PATCH] mgr: drop GIL in get_config Fixes: https://tracker.ceph.com/issues/35985 Signed-off-by: John Spray (cherry picked from commit d590a53) Conflicts: src/mgr/ActivePyModules.cc --- src/mgr/ActivePyModules.cc | 6 ++---- src/mgr/BaseMgrModule.cc | 4 ++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/mgr/ActivePyModules.cc b/src/mgr/ActivePyModules.cc index ea7128c53996f..20f35c9c086fc 100644 --- a/src/mgr/ActivePyModules.cc +++ b/src/mgr/ActivePyModules.cc @@ -420,15 +420,13 @@ void ActivePyModules::notify_all(const LogEntry &log_entry) bool ActivePyModules::get_config(const std::string &module_name, const std::string &key, std::string *val) const { - PyThreadState *tstate = PyEval_SaveThread(); - Mutex::Locker l(lock); - PyEval_RestoreThread(tstate); - const std::string global_key = PyModuleRegistry::config_prefix + module_name + "/" + key; dout(4) << __func__ << "key: " << global_key << dendl; + Mutex::Locker l(lock); + if (config_cache.count(global_key)) { *val = config_cache.at(global_key); return true; diff --git a/src/mgr/BaseMgrModule.cc b/src/mgr/BaseMgrModule.cc index 6777a5238881c..cc9904d0adb56 100644 --- a/src/mgr/BaseMgrModule.cc +++ b/src/mgr/BaseMgrModule.cc @@ -356,9 +356,13 @@ ceph_config_get(BaseMgrModule *self, PyObject *args) return nullptr; } + PyThreadState *tstate = PyEval_SaveThread(); std::string value; bool found = self->py_modules->get_config(self->this_module->get_name(), what, &value); + + PyEval_RestoreThread(tstate); + if (found) { dout(10) << "ceph_config_get " << what << " found: " << value.c_str() << dendl; return PyString_FromString(value.c_str()); -- 2.39.5