From 06d8133147b492e9421f2a2c25fc01cc65fb21d8 Mon Sep 17 00:00:00 2001 From: Christof Schmitt Date: Wed, 23 Aug 2017 14:37:28 -0700 Subject: [PATCH] vfs_default: Fix passing of errno from async calls 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 Reviewed-by: Jeremy Allison (cherry picked from commit a6f391b8dd1fbfd1a370667dec1374284984c341) --- source3/modules/vfs_default.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 53a116c..ce1b6e2 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -722,7 +722,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; @@ -796,7 +795,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); @@ -845,7 +846,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; @@ -919,7 +919,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); @@ -968,7 +970,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; @@ -1029,7 +1030,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); -- 1.8.3.1