]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rados.py: keep reference to python callbacks 3935/head
authorJosh Durgin <jdurgin@redhat.com>
Tue, 10 Feb 2015 04:50:23 +0000 (20:50 -0800)
committerLoic Dachary <ldachary@redhat.com>
Thu, 12 Mar 2015 21:17:12 +0000 (22:17 +0100)
If we don't keep a reference to these, the librados aio calls will
segfault since the python-level callbacks will have been garbage
collected. Passing them to aio_create_completion() does not take a
reference to them. Keep a reference in the python Completion object
associated with the request, since they need the same lifetime.

This fixes a regression from 60b019f69aa0e39d276c669698c92fc890599f50.

Fixes: #10775
Backport: dumpling, firefly, giant
Signed-off-by: Josh Durgin <jdurgin@redhat.com>
(cherry picked from commit 36d37aadbbbece28d70e827511f1a473d851463d)

src/pybind/rados.py

index d7a8ba226801645d0c7ceded4cd2b8a1514bae0c..e3f8435aaacf5a0671e09126372bedab0a182b37 100644 (file)
@@ -829,11 +829,14 @@ class Snap(object):
 
 class Completion(object):
     """completion object"""
-    def __init__(self, ioctx, rados_comp, oncomplete, onsafe):
+    def __init__(self, ioctx, rados_comp, oncomplete, onsafe,
+                 complete_cb, safe_cb):
         self.rados_comp = rados_comp
         self.oncomplete = oncomplete
         self.onsafe = onsafe
         self.ioctx = ioctx
+        self.complete_cb = complete_cb
+        self.safe_cb = safe_cb
 
     def wait_for_safe(self):
         """
@@ -952,7 +955,8 @@ class Ioctx(object):
         if ret < 0:
             raise make_ex(ret, "error getting a completion")
         with self.lock:
-            completion_obj = Completion(self, completion, oncomplete, onsafe)
+            completion_obj = Completion(self, completion, oncomplete, onsafe,
+                                        complete_cb, safe_cb)
             if oncomplete:
                 self.complete_cbs[completion.value] = completion_obj
             if onsafe: