From 54f74325c7bdb213300564ad1ff0a62e9a706976 Mon Sep 17 00:00:00 2001 From: Dan Mick Date: Tue, 18 Jun 2013 11:05:10 -0700 Subject: [PATCH] rados.py: return error strings even if ret != 0 Key rados_free() off returned length, not ret Signed-off-by: Dan Mick Reviewed-by: Sage Weil --- src/pybind/rados.py | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/src/pybind/rados.py b/src/pybind/rados.py index c4000465272..90b7ffd9874 100644 --- a/src/pybind/rados.py +++ b/src/pybind/rados.py @@ -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)