diff options
author | Volker Lendecke <vl@samba.org> | 2012-07-13 10:22:25 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2012-07-18 15:48:04 -0700 |
commit | 5d09cec6fe499ac0bcc1ac98fd8aaffe7e43faa3 (patch) | |
tree | b1438456ff31f7e522089f6569f67c078d6eadc4 /source3/smbd | |
parent | 3882113e6f44d0adbc321d97931a6e9a37a149b8 (diff) | |
download | samba-5d09cec6fe499ac0bcc1ac98fd8aaffe7e43faa3.tar.gz samba-5d09cec6fe499ac0bcc1ac98fd8aaffe7e43faa3.tar.bz2 samba-5d09cec6fe499ac0bcc1ac98fd8aaffe7e43faa3.zip |
s3-vfs: async fsync
Signed-off-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/vfs.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 48d74cd17a..349f0a0b2f 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -1725,6 +1725,68 @@ int smb_vfs_call_fsync(struct vfs_handle_struct *handle, return handle->fns->fsync_fn(handle, fsp); } +struct smb_vfs_call_fsync_state { + int (*recv_fn)(struct tevent_req *req, int *err); + int retval; +}; + +static void smb_vfs_call_fsync_done(struct tevent_req *subreq); + +struct tevent_req *smb_vfs_call_fsync_send(struct vfs_handle_struct *handle, + TALLOC_CTX *mem_ctx, + struct tevent_context *ev, + struct files_struct *fsp) +{ + struct tevent_req *req, *subreq; + struct smb_vfs_call_fsync_state *state; + + req = tevent_req_create(mem_ctx, &state, + struct smb_vfs_call_fsync_state); + if (req == NULL) { + return NULL; + } + VFS_FIND(fsync_send); + state->recv_fn = handle->fns->fsync_recv_fn; + + subreq = handle->fns->fsync_send_fn(handle, state, ev, fsp); + if (tevent_req_nomem(subreq, req)) { + return tevent_req_post(req, ev); + } + tevent_req_set_callback(subreq, smb_vfs_call_fsync_done, req); + return req; +} + +static void smb_vfs_call_fsync_done(struct tevent_req *subreq) +{ + struct tevent_req *req = tevent_req_callback_data( + subreq, struct tevent_req); + struct smb_vfs_call_fsync_state *state = tevent_req_data( + req, struct smb_vfs_call_fsync_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); +} + +int SMB_VFS_FSYNC_RECV(struct tevent_req *req, int *perrno) +{ + struct smb_vfs_call_fsync_state *state = tevent_req_data( + req, struct smb_vfs_call_fsync_state); + int err; + + if (tevent_req_is_unix_error(req, &err)) { + *perrno = err; + return -1; + } + return state->retval; +} + + int smb_vfs_call_stat(struct vfs_handle_struct *handle, struct smb_filename *smb_fname) { |