s3:smb2_server: optimize smbd_smb2_generate_outbody() for the common case
authorStefan Metzmacher <metze@samba.org>
Wed, 4 Dec 2013 14:05:34 +0000 (15:05 +0100)
committerJeremy Allison <jra@samba.org>
Wed, 5 Mar 2014 21:59:22 +0000 (13:59 -0800)
Use a preallocated buffer for the first response in the compound chain.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/globals.h
source3/smbd/smb2_server.c

index 15fc01272edf8186e6c5767a2fb2474f98bed63b..f5962717f1b91c952ba1092178a6003e5c90bc49 100644 (file)
@@ -615,6 +615,7 @@ struct smbd_smb2_request {
                int vector_count;
 #define OUTVEC_ALLOC_SIZE (SMB2_HDR_BODY + 9)
                uint8_t _hdr[OUTVEC_ALLOC_SIZE];
+               uint8_t _body[0x58];
        } out;
 };
 
index 7fbaf485d7cda1ef09954779debac10ca2272c1f..becbbed66472d7c07aac6115025d3bd61a26a079 100644 (file)
@@ -922,6 +922,12 @@ static void smb2_calculate_credits(const struct smbd_smb2_request *inreq,
 
 DATA_BLOB smbd_smb2_generate_outbody(struct smbd_smb2_request *req, size_t size)
 {
+       if (req->current_idx <= 1) {
+               if (size <= sizeof(req->out._body)) {
+                       return data_blob_const(req->out._body, size);
+               }
+       }
+
        return data_blob_talloc(req->out.vector, NULL, size);
 }