]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:smbd: let aio_add_req_to_fsp() return the pointer to the link
authorAndreas Schneider <asn@samba.org>
Fri, 23 Aug 2024 12:35:07 +0000 (14:35 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Wed, 29 Jan 2025 11:20:33 +0000 (11:20 +0000)
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 <metze@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Andreas Schneider <asn@samba.org>
source3/smbd/proto.h
source3/smbd/smb2_aio.c

index 6ed89b2b8e1663f92bdaeeb33edb67d39e7e10b0..33bfd5b7ae40575fbecd286c056bf21a09b6a675 100644 (file)
@@ -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);
index 7430a830f1bcbda890e9737c834bdd427564c264..fc97bdc075abd17451a1b80b5465c2ab587b7866 100644 (file)
@@ -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 {