]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rados.py: return error strings even if ret != 0
authorDan Mick <dan.mick@inktank.com>
Tue, 18 Jun 2013 18:05:10 +0000 (11:05 -0700)
committerDan Mick <dan.mick@inktank.com>
Tue, 18 Jun 2013 21:22:47 +0000 (14:22 -0700)
Key rados_free() off returned length, not ret

Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
src/pybind/rados.py

index c40004652727977b85e16419845eaa533d150dec..90b7ffd9874055710bd875d85085e86a1f033da6 100644 (file)
@@ -544,17 +544,15 @@ Rados object in state %s." % (self.state))
                                  outbufp, byref(outbuflen), outsp, byref(outslen)),
                                 timeout)
 
-        if ret == 0:
-            # copy returned memory (ctypes makes a copy, not a reference)
-            my_outbuf = outbufp.contents[:(outbuflen.value)]
-            my_outs = outsp.contents[:(outslen.value)]
+        # copy returned memory (ctypes makes a copy, not a reference)
+        my_outbuf = outbufp.contents[:(outbuflen.value)]
+        my_outs = outsp.contents[:(outslen.value)]
 
-            # free callee's allocations
+        # free callee's allocations
+        if outbuflen.value:
             run_in_thread(self.librados.rados_buffer_free, (outbufp.contents,))
+        if outslen.value:
             run_in_thread(self.librados.rados_buffer_free, (outsp.contents,))
-        else:
-            my_outbuf = ''
-            my_outs = ''
 
         return (ret, my_outbuf, my_outs)
 
@@ -576,17 +574,15 @@ Rados object in state %s." % (self.state))
                             outbufp, byref(outbuflen), outsp, byref(outslen)),
                             timeout)
 
-        if ret == 0:
-            # copy returned memory
-            my_outbuf = outbufp.contents[:(outbuflen.value)]
-            my_outs = outsp.contents[:(outslen.value)]
+        # copy returned memory (ctypes makes a copy, not a reference)
+        my_outbuf = outbufp.contents[:(outbuflen.value)]
+        my_outs = outsp.contents[:(outslen.value)]
 
-            # free callee's allocations
+        # free callee's allocations
+        if outbuflen.value:
             run_in_thread(self.librados.rados_buffer_free, (outbufp.contents,))
+        if outslen.value:
             run_in_thread(self.librados.rados_buffer_free, (outsp.contents,))
-        else:
-            my_outbuf = ''
-            my_outs = ''
 
         return (ret, my_outbuf, my_outs)
 
@@ -608,17 +604,15 @@ Rados object in state %s." % (self.state))
                             outbufp, byref(outbuflen), outsp, byref(outslen)),
                             timeout)
 
-        if ret == 0:
-            # copy returned memory
-            my_outbuf = outbufp.contents[:(outbuflen.value)]
-            my_outs = outsp.contents[:(outslen.value)]
+        # copy returned memory (ctypes makes a copy, not a reference)
+        my_outbuf = outbufp.contents[:(outbuflen.value)]
+        my_outs = outsp.contents[:(outslen.value)]
 
-            # free callee's allocations
+        # free callee's allocations
+        if outbuflen.value:
             run_in_thread(self.librados.rados_buffer_free, (outbufp.contents,))
+        if outslen.value:
             run_in_thread(self.librados.rados_buffer_free, (outsp.contents,))
-        else:
-            my_outbuf = ''
-            my_outs = ''
 
         return (ret, my_outbuf, my_outs)