s3:smbd: add support for canceling SMB2 Notify calls.
authorStefan Metzmacher <metze@samba.org>
Sat, 15 Aug 2009 08:11:16 +0000 (10:11 +0200)
committerStefan Metzmacher <metze@samba.org>
Mon, 17 Aug 2009 07:25:46 +0000 (09:25 +0200)
metze

source3/smbd/smb2_notify.c

index 4d21b27ff83103ed0a65184287c6a51ac12a2f9a..fb465abff9af1c1507a6f5368ff81c090c4d1a98 100644 (file)
@@ -155,6 +155,7 @@ static void smbd_smb2_request_notify_done(struct tevent_req *subreq)
 
 struct smbd_smb2_notify_state {
        struct smbd_smb2_request *smb2req;
+       struct smb_request *smbreq;
        struct tevent_immediate *im;
        NTSTATUS status;
        DATA_BLOB out_output_buffer;
@@ -166,6 +167,7 @@ static void smbd_smb2_notify_reply(struct smb_request *smbreq,
 static void smbd_smb2_notify_reply_trigger(struct tevent_context *ctx,
                                           struct tevent_immediate *im,
                                           void *private_data);
+static bool smbd_smb2_notify_cancel(struct tevent_req *req);
 
 static struct tevent_req *smbd_smb2_notify_send(TALLOC_CTX *mem_ctx,
                                                struct tevent_context *ev,
@@ -201,6 +203,7 @@ static struct tevent_req *smbd_smb2_notify_send(TALLOC_CTX *mem_ctx,
                return tevent_req_post(req, ev);
        }
 
+       state->smbreq = smbreq;
        smbreq->async_priv = (void *)req;
 
        fsp = file_fsp(smbreq, (uint16_t)in_file_id_volatile);
@@ -293,6 +296,9 @@ static struct tevent_req *smbd_smb2_notify_send(TALLOC_CTX *mem_ctx,
                return tevent_req_post(req, ev);
        }
 
+       /* allow this request to be canceled */
+       tevent_req_set_cancel_fn(req, smbd_smb2_notify_cancel);
+
        return req;
 }
 
@@ -350,6 +356,17 @@ static void smbd_smb2_notify_reply_trigger(struct tevent_context *ctx,
        tevent_req_done(req);
 }
 
+static bool smbd_smb2_notify_cancel(struct tevent_req *req)
+{
+       struct smbd_smb2_notify_state *state = tevent_req_data(req,
+                                              struct smbd_smb2_notify_state);
+
+       smbd_notify_cancel_by_smbreq(state->smb2req->sconn,
+                                    state->smbreq);
+
+       return true;
+}
+
 static NTSTATUS smbd_smb2_notify_recv(struct tevent_req *req,
                                      TALLOC_CTX *mem_ctx,
                                      DATA_BLOB *out_output_buffer)