Skip to content

Commit

Permalink
pybind/rados/rados: do not pass prval from stack
Browse files Browse the repository at this point in the history
The prval is a pointer to an int to write the final completion code of
the rados op.  This can't be on the stack since we immediately leave the
current scope after preparing the op (looong before we do the rados op).

We keep the tuple return value to avoid breaking users of this API
(devicehealth module, gnocchi at a minimum).

Fixes: http://tracker.ceph.com/issues/25175
Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 8e36f18)
  • Loading branch information
liewegas authored and smithfarm committed Sep 2, 2018
1 parent 42cfc1b commit bc5e497
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/pybind/rados/rados.pyx
Expand Up @@ -3511,14 +3511,13 @@ returned %d, but should return zero on success." % (self.name, ret))
ReadOp _read_op = read_op
rados_omap_iter_t iter_addr = NULL
int _max_return = max_return
int prval = 0

with nogil:
rados_read_op_omap_get_vals2(_read_op.read_op, _start_after, _filter_prefix,
_max_return, &iter_addr, NULL, &prval)
_max_return, &iter_addr, NULL, NULL)
it = OmapIterator(self)
it.ctx = iter_addr
return it, int(prval)
return it, 0 # 0 is meaningless; there for backward-compat

@requires(('read_op', ReadOp), ('start_after', str_type), ('max_return', int))
def get_omap_keys(self, read_op, start_after, max_return):
Expand All @@ -3538,14 +3537,13 @@ returned %d, but should return zero on success." % (self.name, ret))
ReadOp _read_op = read_op
rados_omap_iter_t iter_addr = NULL
int _max_return = max_return
int prval = 0

with nogil:
rados_read_op_omap_get_keys2(_read_op.read_op, _start_after,
_max_return, &iter_addr, NULL, &prval)
_max_return, &iter_addr, NULL, NULL)
it = OmapIterator(self)
it.ctx = iter_addr
return it, int(prval)
return it, 0 # 0 is meaningless; there for backward-compat

@requires(('read_op', ReadOp), ('keys', tuple))
def get_omap_vals_by_keys(self, read_op, keys):
Expand All @@ -3563,16 +3561,15 @@ returned %d, but should return zero on success." % (self.name, ret))
rados_omap_iter_t iter_addr
char **_keys = to_bytes_array(keys)
size_t key_num = len(keys)
int prval = 0

try:
with nogil:
rados_read_op_omap_get_vals_by_keys(_read_op.read_op,
<const char**>_keys,
key_num, &iter_addr, &prval)
key_num, &iter_addr, NULL)
it = OmapIterator(self)
it.ctx = iter_addr
return it, int(prval)
return it, 0 # 0 is meaningless; there for backward-compat
finally:
free(_keys)

Expand Down

0 comments on commit bc5e497

Please sign in to comment.