From db03d3027f876fbe94e11d395659abee87986c74 Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Fri, 9 Oct 2015 14:59:01 -0700 Subject: [PATCH] pybind/rados: Fix binary omap values. The prior code caused binary omap values to be discarded. This fixes them to use the same model as the xattr iterator, and correctly return binary data as python strings, eg: 'object_prefix': '\x15\x00\x00\x00rbd_data.449d2ae8944a' Signed-off-by: Robin H. Johnson --- src/pybind/rados.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/pybind/rados.py b/src/pybind/rados.py index ccada723c366..2172d0230720 100644 --- a/src/pybind/rados.py +++ b/src/pybind/rados.py @@ -846,17 +846,20 @@ class OmapIterator(object): Get the next key-value pair in the object :returns: next rados.OmapItem """ - key = c_char_p() - value = c_char_p() - lens = c_int() - run_in_thread(self.ioctx.librados.rados_omap_get_next, - (self.ctx, pointer(key), pointer(value), - pointer(lens))) - if key.value is None and value.value is None: + key_ = c_char_p(0) + val_ = c_char_p(0) + len_ = c_int(0) + ret = run_in_thread(self.ioctx.librados.rados_omap_get_next, + (self.ctx, byref(key_), byref(val_), byref(len_))) + if (ret != 0): + raise make_ex(ret, "error iterating over the omap") + if key_.value is None: raise StopIteration() - if lens.value: - value.value = value.value[0:lens.value] - return (key.value, value.value) + key = ctypes.string_at(key_) + val = None + if val_.value is not None: + val = ctypes.string_at(val_, len_) + return (key, val) def __del__(self): run_in_thread(self.ioctx.librados.rados_omap_get_end, (self.ctx,)) -- 2.47.3