vfs_default: Fix passing of errno from async calls
authorChristof Schmitt <cs@samba.org>
Wed, 23 Aug 2017 21:37:28 +0000 (14:37 -0700)
committerJeremy Allison <jra@samba.org>
Wed, 23 Aug 2017 23:46:08 +0000 (01:46 +0200)
Current code assigns errno from async pthreadpool calls to the
vfs_default internal vfswrap_*_state.  The callers of the vfs_*_recv
functions expect the value from errno in vfs_aio_state.error.

Correctly assign errno to vfs_aio_state.error and remove the unused
internal err variable.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12983

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_default.c

index fbfe654f1fd3fadad0ed00f5f2695f6d39eee55e..0a56e457ab925102543bef3299b398c26cb7a130 100644 (file)
@@ -738,7 +738,6 @@ static int vfswrap_init_pool(struct smbd_server_connection *conn)
 
 struct vfswrap_pread_state {
        ssize_t ret;
-       int err;
        int fd;
        void *buf;
        size_t count;
@@ -812,7 +811,9 @@ static void vfs_pread_do(void *private_data)
                                   state->offset);
        } while ((state->ret == -1) && (errno == EINTR));
 
-       state->err = errno;
+       if (state->ret == -1) {
+               state->vfs_aio_state.error = errno;
+       }
 
        PROFILE_TIMESTAMP(&end_time);
 
@@ -861,7 +862,6 @@ static ssize_t vfswrap_pread_recv(struct tevent_req *req,
 
 struct vfswrap_pwrite_state {
        ssize_t ret;
-       int err;
        int fd;
        const void *buf;
        size_t count;
@@ -935,7 +935,9 @@ static void vfs_pwrite_do(void *private_data)
                                   state->offset);
        } while ((state->ret == -1) && (errno == EINTR));
 
-       state->err = errno;
+       if (state->ret == -1) {
+               state->vfs_aio_state.error = errno;
+       }
 
        PROFILE_TIMESTAMP(&end_time);
 
@@ -984,7 +986,6 @@ static ssize_t vfswrap_pwrite_recv(struct tevent_req *req,
 
 struct vfswrap_fsync_state {
        ssize_t ret;
-       int err;
        int fd;
 
        struct vfs_aio_state vfs_aio_state;
@@ -1045,7 +1046,9 @@ static void vfs_fsync_do(void *private_data)
                state->ret = fsync(state->fd);
        } while ((state->ret == -1) && (errno == EINTR));
 
-       state->err = errno;
+       if (state->ret == -1) {
+               state->vfs_aio_state.error = errno;
+       }
 
        PROFILE_TIMESTAMP(&end_time);