diff options
author | Volker Lendecke <vl@samba.org> | 2012-06-26 14:30:59 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2012-07-18 13:49:21 -0700 |
commit | c6e456d9c08eb0d05904802e0f23f15676a13e0d (patch) | |
tree | 6066546f482f0dc83285fb5aec0639d4d98d5053 /source3/smbd/vfs.c | |
parent | d44ccdd4378d6aafd1dd6322e419d1165635f25b (diff) | |
download | samba-c6e456d9c08eb0d05904802e0f23f15676a13e0d.tar.gz samba-c6e456d9c08eb0d05904802e0f23f15676a13e0d.tar.bz2 samba-c6e456d9c08eb0d05904802e0f23f15676a13e0d.zip |
s3-vfs: async pwrite
Signed-off-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/smbd/vfs.c')
-rw-r--r-- | source3/smbd/vfs.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 32e3472efe..9b666e0bf6 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -30,6 +30,7 @@ #include "memcache.h" #include "transfer_file.h" #include "ntioctl.h" +#include "lib/util/tevent_unix.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_VFS @@ -1556,6 +1557,70 @@ ssize_t smb_vfs_call_pwrite(struct vfs_handle_struct *handle, return handle->fns->pwrite_fn(handle, fsp, data, n, offset); } +struct smb_vfs_call_pwrite_state { + ssize_t (*recv_fn)(struct tevent_req *req, int *err); + ssize_t retval; +}; + +static void smb_vfs_call_pwrite_done(struct tevent_req *subreq); + +struct tevent_req *smb_vfs_call_pwrite_send(struct vfs_handle_struct *handle, + TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct files_struct *fsp, + const void *data, + size_t n, off_t offset) +{ + struct tevent_req *req, *subreq; + struct smb_vfs_call_pwrite_state *state; + + req = tevent_req_create(mem_ctx, &state, + struct smb_vfs_call_pwrite_state); + if (req == NULL) { + return NULL; + } + VFS_FIND(pwrite_send); + state->recv_fn = handle->fns->pwrite_recv_fn; + + subreq = handle->fns->pwrite_send_fn(handle, state, ev, fsp, data, n, + offset); + if (tevent_req_nomem(subreq, req)) { + return tevent_req_post(req, ev); + } + tevent_req_set_callback(subreq, smb_vfs_call_pwrite_done, req); + return req; +} + +static void smb_vfs_call_pwrite_done(struct tevent_req *subreq) +{ + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct smb_vfs_call_pwrite_state *state = tevent_req_data( + req, struct smb_vfs_call_pwrite_state); + int err; + + state->retval = state->recv_fn(subreq, &err); + TALLOC_FREE(subreq); + if (state->retval == -1) { + tevent_req_error(req, err); + return; + } + tevent_req_done(req); +} + +ssize_t SMB_VFS_PWRITE_RECV(struct tevent_req *req, int *perrno) +{ + struct smb_vfs_call_pwrite_state *state = tevent_req_data( + req, struct smb_vfs_call_pwrite_state); + int err; + + if (tevent_req_is_unix_error(req, &err)) { + *perrno = err; + return -1; + } + return state->retval; +} + off_t smb_vfs_call_lseek(struct vfs_handle_struct *handle, struct files_struct *fsp, off_t offset, int whence) |