]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
pybind/rados: Fix error handling and leaks in aio
authorHector Martin <marcan@marcan.st>
Wed, 24 Feb 2016 10:54:25 +0000 (19:54 +0900)
committerHector Martin <marcan@marcan.st>
Wed, 24 Feb 2016 15:10:10 +0000 (00:10 +0900)
commit3c767ab81520c73b9ffb4fface257d4b68ea4615
tree938d36184b00d599d8e961b60bc8b4152ade09f9
parentdc5a9053ce69c0630091774f16ce421da67d26fb
pybind/rados: Fix error handling and leaks in aio

aio_read:
The reference to ret_s begins existing at PyBytes_FromStringAndSize and
is handed over to the callback if rados_aio_read succeeds. This creates
a lot of subtle scenarios where it might not be XDECREFed (e.g. if
a KeyboardInterrupt arrives at the wrong time). Instead, store the pointer
to that buffer in the completion object, and hand over responsibility for
the XDECREF to it. This guarantees that the "special" reference to this
incomplete object will be released when the completion object is
deallocated.

Also make sure we don't try to _PyBytes_Resize with a negative length.

Add a failure case to the aio_read test in test_rados.py

Completion: the wrapper methods weren't being called, which prevents
the completion objects from being freed until the Ioctx is. Fix this
and add a refcount check to the aio_read test.

Signed-off-by: Hector Martin <marcan@marcan.st>
src/pybind/rados/rados.pyx
src/test/pybind/test_rados.py