diff options
author | Stefan Metzmacher <metze@samba.org> | 2013-11-20 09:56:19 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2014-03-05 13:59:20 -0800 |
commit | ec498a2414d96567bfed26f35b60ebe1ac40c68b (patch) | |
tree | e3bfebc069c2dfb6a1613889c06257c121084a98 /source3 | |
parent | 66877dfaa59561145eba6233dc1f43c282d8cd08 (diff) | |
download | samba-ec498a2414d96567bfed26f35b60ebe1ac40c68b.tar.gz samba-ec498a2414d96567bfed26f35b60ebe1ac40c68b.tar.xz samba-ec498a2414d96567bfed26f35b60ebe1ac40c68b.zip |
s3:smb2_server: optimize smbd_smb2_request_setup_out()
We can use a preallocated buffer for the possible error
response of the first response in the compound chain.
This avoids a talloc_array_zero() call for the common case.
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 | 2 | ||||
-rw-r--r-- | source3/smbd/smb2_server.c | 14 |
2 files changed, 10 insertions, 6 deletions
diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index 2b7fc7ec51..781379c986 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -611,6 +611,8 @@ struct smbd_smb2_request { */ struct iovec *vector; int vector_count; +#define OUTVEC_ALLOC_SIZE (SMB2_HDR_BODY + 9) + uint8_t _hdr[OUTVEC_ALLOC_SIZE]; } out; }; diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c index 192e99c814..c98766247d 100644 --- a/source3/smbd/smb2_server.c +++ b/source3/smbd/smb2_server.c @@ -37,8 +37,6 @@ static void smbd_smb2_connection_handler(struct tevent_context *ev, static NTSTATUS smbd_smb2_io_handler(struct smbd_server_connection *sconn, uint16_t fde_flags); -#define OUTVEC_ALLOC_SIZE (SMB2_HDR_BODY + 9) - static const struct smbd_smb2_dispatch_table { uint16_t opcode; const char *name; @@ -948,10 +946,14 @@ static NTSTATUS smbd_smb2_request_setup_out(struct smbd_smb2_request *req) next_command_ofs = SMB2_HDR_BODY + 9; } - outhdr = talloc_zero_array(vector, uint8_t, - OUTVEC_ALLOC_SIZE); - if (outhdr == NULL) { - return NT_STATUS_NO_MEMORY; + if (idx == 1) { + outhdr = req->out._hdr; + } else { + outhdr = talloc_zero_array(vector, uint8_t, + OUTVEC_ALLOC_SIZE); + if (outhdr == NULL) { + return NT_STATUS_NO_MEMORY; + } } outbody = outhdr + SMB2_HDR_BODY; |