summaryrefslogtreecommitdiffstats
path: root/source3
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2013-12-04 15:05:34 +0100
committerJeremy Allison <jra@samba.org>2014-03-05 13:59:22 -0800
commitadaf517c87db22cb5b74906d43cfbae74a07130c (patch)
tree048d547f495a79bed6a7effb0aa584fafcfa9533 /source3
parentd307953e08038cf4ba0367a85296d9f3b11d51d7 (diff)
downloadsamba-adaf517c87db22cb5b74906d43cfbae74a07130c.tar.gz
samba-adaf517c87db22cb5b74906d43cfbae74a07130c.tar.xz
samba-adaf517c87db22cb5b74906d43cfbae74a07130c.zip
s3:smb2_server: optimize smbd_smb2_generate_outbody() for the common case
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>
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/globals.h1
-rw-r--r--source3/smbd/smb2_server.c6
2 files changed, 7 insertions, 0 deletions
diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h
index 15fc01272ed..f5962717f1b 100644
--- a/source3/smbd/globals.h
+++ b/source3/smbd/globals.h
@@ -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;
};
diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c
index 7fbaf485d7c..becbbed6647 100644
--- a/source3/smbd/smb2_server.c
+++ b/source3/smbd/smb2_server.c
@@ -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);
}