From: Andreas Schneider Date: Fri, 23 Aug 2024 09:46:33 +0000 (+0200) Subject: libcli:smb: Implement smb2cli_notify_set_notify_async() X-Git-Tag: tdb-1.4.13~55 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e2969ed00fd85d5b2bf62d2a17643b5f8481b278;p=thirdparty%2Fsamba.git libcli:smb: Implement smb2cli_notify_set_notify_async() BUG: https://bugzilla.samba.org/show_bug.cgi?id=14430 Pair-Programmed-With: Stefan Metzmacher Signed-off-by: Stefan Metzmacher Signed-off-by: Andreas Schneider --- diff --git a/libcli/smb/smb2cli_notify.c b/libcli/smb/smb2cli_notify.c index 9026a6b1c30..6cf9ae7ce72 100644 --- a/libcli/smb/smb2cli_notify.c +++ b/libcli/smb/smb2cli_notify.c @@ -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; } diff --git a/libcli/smb/smbXcli_base.h b/libcli/smb/smbXcli_base.h index 42f227c4fef..2e60201c9a0 100644 --- a/libcli/smb/smbXcli_base.h +++ b/libcli/smb/smbXcli_base.h @@ -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,