summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2008-12-20 10:51:54 +0100
committerVolker Lendecke <vl@samba.org>2009-01-02 22:11:50 +0100
commitb4e1eb4345ab0be00e31d09cf0753597ef0af44a (patch)
tree716577212cb5be530cbfad297216eba0c8f19cc5
parentaed8c7bfcfb3c860758d39d476ca87ef9eda2b6d (diff)
downloadsamba-b4e1eb4345ab0be00e31d09cf0753597ef0af44a.tar.gz
samba-b4e1eb4345ab0be00e31d09cf0753597ef0af44a.tar.bz2
samba-b4e1eb4345ab0be00e31d09cf0753597ef0af44a.zip
Optimize for the common case that packet.c received exactly one full packet
-rw-r--r--source3/lib/packet.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/source3/lib/packet.c b/source3/lib/packet.c
index 72de30e8ca..ef28bf9f62 100644
--- a/source3/lib/packet.c
+++ b/source3/lib/packet.c
@@ -140,15 +140,21 @@ bool packet_handler(struct packet_context *ctx,
return true;
}
- buf = (uint8_t *)TALLOC_MEMDUP(ctx, ctx->in.data, length);
- if (buf == NULL) {
- *status = NT_STATUS_NO_MEMORY;
- return true;
- }
+ if (length == ctx->in.length) {
+ buf = ctx->in.data;
+ ctx->in.data = NULL;
+ ctx->in.length = 0;
+ } else {
+ buf = (uint8_t *)TALLOC_MEMDUP(ctx, ctx->in.data, length);
+ if (buf == NULL) {
+ *status = NT_STATUS_NO_MEMORY;
+ return true;
+ }
- memmove(ctx->in.data, ctx->in.data + length,
- ctx->in.length - length);
- ctx->in.length -= length;
+ memmove(ctx->in.data, ctx->in.data + length,
+ ctx->in.length - length);
+ ctx->in.length -= length;
+ }
*status = callback(buf, length, priv);
return True;