diff options
author | Stefan Metzmacher <metze@samba.org> | 2013-12-04 15:05:34 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2014-03-05 13:59:22 -0800 |
commit | adaf517c87db22cb5b74906d43cfbae74a07130c (patch) | |
tree | 048d547f495a79bed6a7effb0aa584fafcfa9533 /source3 | |
parent | d307953e08038cf4ba0367a85296d9f3b11d51d7 (diff) | |
download | samba-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.h | 1 | ||||
-rw-r--r-- | source3/smbd/smb2_server.c | 6 |
2 files changed, 7 insertions, 0 deletions
diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index 15fc01272e..f5962717f1 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 7fbaf485d7..becbbed664 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); } |