From: Andreas Schneider Date: Fri, 23 Aug 2024 12:35:07 +0000 (+0200) Subject: s3:smbd: let aio_add_req_to_fsp() return the pointer to the link X-Git-Tag: tdb-1.4.13~45 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bb26e104d6466bdc153508d670370c5d54fc032e;p=thirdparty%2Fsamba.git s3:smbd: let aio_add_req_to_fsp() return the pointer to the link This allows the caller to free the link before the request. 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/source3/smbd/proto.h b/source3/smbd/proto.h index 6ed89b2b8e1..33bfd5b7ae4 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -72,7 +72,8 @@ NTSTATUS schedule_aio_smb2_write(connection_struct *conn, DATA_BLOB in_data, bool write_through); bool cancel_smb2_aio(struct smb_request *smbreq); -bool aio_add_req_to_fsp(files_struct *fsp, struct tevent_req *req); +struct aio_req_fsp_link; +struct aio_req_fsp_link *aio_add_req_to_fsp(files_struct *fsp, struct tevent_req *req); struct aio_extra *create_aio_extra(TALLOC_CTX *mem_ctx, files_struct *fsp, size_t buflen); diff --git a/source3/smbd/smb2_aio.c b/source3/smbd/smb2_aio.c index 7430a830f1b..fc97bdc075a 100644 --- a/source3/smbd/smb2_aio.c +++ b/source3/smbd/smb2_aio.c @@ -113,14 +113,14 @@ static int aio_del_req_from_fsp(struct aio_req_fsp_link *lnk) return 0; } -bool aio_add_req_to_fsp(files_struct *fsp, struct tevent_req *req) +struct aio_req_fsp_link *aio_add_req_to_fsp(files_struct *fsp, struct tevent_req *req) { size_t array_len; struct aio_req_fsp_link *lnk; lnk = talloc(req, struct aio_req_fsp_link); if (lnk == NULL) { - return false; + return NULL; } array_len = talloc_array_length(fsp->aio_requests); @@ -130,7 +130,7 @@ bool aio_add_req_to_fsp(files_struct *fsp, struct tevent_req *req) if (fsp->num_aio_requests + 10 < 10) { /* Integer wrap. */ TALLOC_FREE(lnk); - return false; + return NULL; } /* @@ -142,7 +142,7 @@ bool aio_add_req_to_fsp(files_struct *fsp, struct tevent_req *req) fsp->num_aio_requests+10); if (tmp == NULL) { TALLOC_FREE(lnk); - return false; + return NULL; } fsp->aio_requests = tmp; } @@ -156,7 +156,7 @@ bool aio_add_req_to_fsp(files_struct *fsp, struct tevent_req *req) #endif talloc_set_destructor(lnk, aio_del_req_from_fsp); - return true; + return lnk; } struct pwrite_fsync_state {