summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-11-14 09:33:22 +0100
committerStefan Metzmacher <metze@samba.org>2011-11-15 17:14:13 +0100
commit483b79cfc4af4dd48089b12b279d174f54132e9d (patch)
tree26308eb963b49c02333ac1071cd9293af992de2a
parent3fbf32213a9523ecab4bc201018d94f38b561b0b (diff)
downloadsamba-483b79cfc4af4dd48089b12b279d174f54132e9d.tar.gz
samba-483b79cfc4af4dd48089b12b279d174f54132e9d.tar.bz2
samba-483b79cfc4af4dd48089b12b279d174f54132e9d.zip
s3:smb2_read: make it possible to cancel aio reads
metze
-rw-r--r--source3/smbd/smb2_read.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/source3/smbd/smb2_read.c b/source3/smbd/smb2_read.c
index c3cbbe8084..08622092c6 100644
--- a/source3/smbd/smb2_read.c
+++ b/source3/smbd/smb2_read.c
@@ -169,6 +169,7 @@ static void smbd_smb2_request_read_done(struct tevent_req *subreq)
struct smbd_smb2_read_state {
struct smbd_smb2_request *smb2req;
+ struct smb_request *smbreq;
files_struct *fsp;
uint64_t in_file_id_volatile;
uint32_t in_length;
@@ -364,6 +365,17 @@ NTSTATUS smb2_read_complete(struct tevent_req *req, ssize_t nread, int err)
return NT_STATUS_OK;
}
+static bool smbd_smb2_read_cancel(struct tevent_req *req)
+{
+ struct smbd_smb2_read_state *state =
+ tevent_req_data(req,
+ struct smbd_smb2_read_state);
+
+ state->smb2req->cancelled = true;
+
+ return cancel_smb2_aio(state->smbreq);
+}
+
static struct tevent_req *smbd_smb2_read_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
struct smbd_smb2_request *smb2req,
@@ -403,6 +415,7 @@ static struct tevent_req *smbd_smb2_read_send(TALLOC_CTX *mem_ctx,
if (tevent_req_nomem(smbreq, req)) {
return tevent_req_post(req, ev);
}
+ state->smbreq = smbreq;
fsp = file_fsp(smbreq, (uint16_t)in_file_id_volatile);
if (fsp == NULL) {
@@ -466,8 +479,10 @@ static struct tevent_req *smbd_smb2_read_send(TALLOC_CTX *mem_ctx,
if (NT_STATUS_IS_OK(status)) {
/*
- * Doing an async read.
+ * Doing an async read, allow this
+ * request to be canceled
*/
+ tevent_req_set_cancel_fn(req, smbd_smb2_read_cancel);
return req;
}