[27742] in Source-Commits

home help back first fref pref prev next nref lref last post

python-afs commit: Fix error handling in pioctl wrappers

daemon@ATHENA.MIT.EDU (Jonathan D Reed)
Wed Feb 26 16:22:03 2014

Date: Wed, 26 Feb 2014 16:21:56 -0500
From: Jonathan D Reed <jdreed@MIT.EDU>
Message-Id: <201402262121.s1QLLuVR015754@drugstore.mit.edu>
To: source-commits@MIT.EDU

https://github.com/mit-athena/python-afs/commits/2f36f4b8fd735dd1c68267a9e5d403f64d4a2963
commit 2f36f4b8fd735dd1c68267a9e5d403f64d4a2963
Author: Jonathan Reed <jdreed@mit.edu>
Date:   Fri Feb 21 12:03:14 2014 -0500

    Fix error handling in pioctl wrappers
    
    We need to save the value of errno if we hope to do anything useful
    with it, otherwise logging will scribble over it.

 afs/_util.pyx |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/afs/_util.pyx b/afs/_util.pyx
index c3f9770..c80bcd6 100644
--- a/afs/_util.pyx
+++ b/afs/_util.pyx
@@ -27,11 +27,13 @@ cdef extern int pioctl_read(char *path, afs_int32 op, void *outbuffer,
     blob.out_size = size
     blob.out = outbuffer
     code = pioctl(path, op, &blob, follow)
-    log.debug("pioctl_read() returned %d", code)
+    # If we don't save errno here, logging scribbles over it
+    save_errno = errno
+    log.debug("pioctl_read() returned %d (save_errno %d)", code, save_errno)
     # This might work with the rest of OpenAFS, but I'm not convinced
     # the rest of it is consistent
     if code == -1:
-        raise OSError(errno, strerror(errno))
+        raise OSError(save_errno, strerror(save_errno))
     pyafs_error(code)
     return code
 
@@ -56,11 +58,13 @@ cdef extern int pioctl_write(char *path, afs_int32 op, char *inbuffer,
         blob.out_size = outsize
         blob.out = outbuffer
     code = pioctl(path, op, &blob, follow)
-    log.debug("pioctl_write() returned %d", code)
+    # If we don't save errno here, logging scribbles over it
+    save_errno = errno
+    log.debug("pioctl_write() returned %d (errno %d)", code, save_errno)
     # This might work with the rest of OpenAFS, but I'm not convinced
     # the rest of it is consistent
     if code == -1:
-        raise OSError(errno, strerror(errno))
+        raise OSError(save_errno, strerror(save_errno))
     pyafs_error(code)
     return code
 

home help back first fref pref prev next nref lref last post