Skip to content

Commit

Permalink
pybind: fix error handling on getxattr
Browse files Browse the repository at this point in the history
The ctypes bindings returned empty string
instead of raising exception.  This was a bug,
because it made it impossible to detect the
difference between missing xattr and empty
xattr.

Signed-off-by: John Spray <john.spray@redhat.com>
  • Loading branch information
John Spray committed Feb 29, 2016
1 parent 8969ae2 commit adddab4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/pybind/cephfs/cephfs.pyx
Expand Up @@ -705,12 +705,19 @@ cdef class LibCephFS(object):
try:
ret_buf = <char *>realloc_chk(ret_buf, ret_length)
with nogil:
ret = ceph_getxattr(self.cluster, _path, _name, ret_buf, ret_length)
ret = ceph_getxattr(self.cluster, _path, _name, ret_buf,
ret_length)

if ret < 0:
raise make_ex(ret, "error in getxattr")

if ret > ret_length:
ret_buf = <char *>realloc_chk(ret_buf, ret)
with nogil:
ceph_getxattr(self.cluster, _path, _name, ret_buf, ret)
ret = ceph_getxattr(self.cluster, _path, _name, ret_buf,
ret)
if ret < 0:
raise make_ex(ret, "error in getxattr")

return ret_buf[:ret]
finally:
Expand Down

0 comments on commit adddab4

Please sign in to comment.