]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: drop GIL in StandbyPyModule::get_config 27639/head
authorwumingqiao <wumingqiao@beyondcent.com>
Thu, 16 May 2019 01:45:50 +0000 (09:45 +0800)
committerwumingqiao <wumingqiao@beyondcent.com>
Thu, 16 May 2019 01:45:50 +0000 (09:45 +0800)
fix: http://tracker.ceph.com/issues/35985

patch https://github.com/ceph/ceph/pull/26613 addressed a race in ActivePyModules.cc, whilst this patch addresses the race in BaseMgrStandbyModule.cc.

Partial manual backport of 6185bd66a9e9b23f1d1982b0bc12d672c33c6fcd

Signed-off-by: wumingqiao <wumingqiao@beyondcent.com>
src/mgr/BaseMgrStandbyModule.cc
src/mgr/StandbyPyModules.cc

index b7bd0f66383164260111bfda451a094f00c4cd1d..2070aafbd6081c68d20a8902d0d57daa2924f743 100644 (file)
@@ -70,7 +70,9 @@ ceph_config_get(BaseMgrStandbyModule *self, PyObject *args)
   }
 
   std::string value;
+  PyThreadState *tstate = PyEval_SaveThread(); // drop GIL
   bool found = self->this_module->get_config(what, &value);
+  PyEval_RestoreThread(tstate); // re-take GIL
   if (found) {
     dout(10) << "ceph_config_get " << what << " found: " << value.c_str() << dendl;
     return PyString_FromString(value.c_str());
index 46c74e03e4dd4678caae42da0824660272e04a73..47ab8ea8c95e5b44e93cfd237da92e3dfb4a0922 100644 (file)
@@ -168,9 +168,6 @@ void *StandbyPyModules::LoadConfigThread::entry()
 bool StandbyPyModule::get_config(const std::string &key,
                                  std::string *value) const
 {
-  PyThreadState *tstate = PyEval_SaveThread();
-  PyEval_RestoreThread(tstate);
-
   const std::string global_key = PyModuleRegistry::config_prefix
     + module_name + "/" + key;