]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: fix ~MonCommandCompletion
authorJohn Spray <john.spray@redhat.com>
Tue, 17 Oct 2017 22:14:43 +0000 (18:14 -0400)
committerJohn Spray <john.spray@redhat.com>
Wed, 1 Nov 2017 12:21:42 +0000 (08:21 -0400)
This was doing a Py_DECREF outside of the Gil.

Fixes: http://tracker.ceph.com/issues/21593
Signed-off-by: John Spray <john.spray@redhat.com>
src/mgr/BaseMgrModule.cc

index 6f7252e86b1596fa8e6ed9182f83cb3f58d1ac69..95e75492c932f6f40ea3827e85828f65c3a5ed93 100644 (file)
@@ -64,11 +64,19 @@ public:
 
   ~MonCommandCompletion() override
   {
-    Py_DECREF(python_completion);
+    if (python_completion) {
+      // Usually do this in finish(): this path is only for if we're
+      // being destroyed without completing.
+      Gil gil(pThreadState, true);
+      Py_DECREF(python_completion);
+      python_completion = nullptr;
+    }
   }
 
   void finish(int r) override
   {
+    assert(python_completion != nullptr);
+
     dout(10) << "MonCommandCompletion::finish()" << dendl;
     {
       // Scoped so the Gil is released before calling notify_all()
@@ -92,6 +100,10 @@ public:
        Py_DECREF(rtn);
       }
       Py_DECREF(args);
+      Py_DECREF(set_fn);
+
+      Py_DECREF(python_completion);
+      python_completion = nullptr;
     }
     py_modules->notify_all("command", tag);
   }