From: Robin H. Johnson Date: Fri, 9 Oct 2015 21:59:01 +0000 (-0700) Subject: pybind/rados: Fix binary omap values. X-Git-Tag: v9.1.0~3^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=db03d3027f876fbe94e11d395659abee87986c74;p=ceph.git 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 --- 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,))