]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libcli:smb: Implement smb2cli_notify_set_notify_async()
authorAndreas Schneider <asn@samba.org>
Fri, 23 Aug 2024 09:46:33 +0000 (11:46 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Wed, 29 Jan 2025 11:20:33 +0000 (11:20 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14430

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Andreas Schneider <asn@samba.org>
libcli/smb/smb2cli_notify.c
libcli/smb/smbXcli_base.h

index 9026a6b1c30d6d2ea04bde90fdb587bab92debf4..6cf9ae7ce7279a96b1835d43ea3e2bab3bd04d51 100644 (file)
@@ -33,6 +33,8 @@ struct smb2cli_notify_state {
 
        struct tevent_req *subreq;
        struct tevent_req *timeout_subreq;
+       bool notify_async;
+       bool report_pending;
 };
 
 static void smb2cli_notify_done(struct tevent_req *subreq);
@@ -133,6 +135,16 @@ static void smb2cli_notify_timedout(struct tevent_req *subreq)
        }
 }
 
+void smb2cli_notify_set_notify_async(struct tevent_req *req)
+{
+       struct smb2cli_notify_state *state =
+               tevent_req_data(req,
+               struct smb2cli_notify_state);
+
+       smb2cli_req_set_notify_async(state->subreq);
+       state->notify_async = true;
+}
+
 static void smb2cli_notify_done(struct tevent_req *subreq)
 {
        struct tevent_req *req = tevent_req_callback_data(
@@ -149,10 +161,20 @@ static void smb2cli_notify_done(struct tevent_req *subreq)
        }
        };
 
+       SMB_ASSERT(state->subreq == subreq);
+
        status = smb2cli_req_recv(subreq, state, &iov,
                                  expected, ARRAY_SIZE(expected));
+       if (NT_STATUS_EQUAL(status, NT_STATUS_PENDING) && state->notify_async) {
+               state->notify_async = false;
+               state->report_pending = true;
+               tevent_req_notify_callback(req);
+               return;
+       }
+       state->notify_async = false;
+       state->report_pending = false;
+       state->subreq = NULL;
        TALLOC_FREE(subreq);
-
        if (NT_STATUS_EQUAL(status, NT_STATUS_CANCELLED)) {
                status = NT_STATUS_IO_TIMEOUT;
        }
@@ -181,6 +203,12 @@ NTSTATUS smb2cli_notify_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
                req, struct smb2cli_notify_state);
        NTSTATUS status;
 
+       if (state->report_pending) {
+               *data_length = 0;
+               *data = NULL;
+               return NT_STATUS_PENDING;
+       }
+
        if (tevent_req_is_nterror(req, &status)) {
                return status;
        }
index 42f227c4fef3a3e0a430f48a90843b3073b15f6e..2e60201c9a021bdcfd30c551490405f70faf45ce 100644 (file)
@@ -897,6 +897,7 @@ struct tevent_req *smb2cli_notify_send(TALLOC_CTX *mem_ctx,
                                       uint64_t fid_volatile,
                                       uint32_t completion_filter,
                                       bool recursive);
+void smb2cli_notify_set_notify_async(struct tevent_req *req);
 NTSTATUS smb2cli_notify_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
                             uint8_t **data, uint32_t *data_length);
 NTSTATUS smb2cli_notify(struct smbXcli_conn *conn,