common/io: Keep queue buffer size multiple of 4K
authorAmitay Isaacs <amitay@gmail.com>
Mon, 5 Aug 2013 07:28:47 +0000 (17:28 +1000)
committerAmitay Isaacs <amitay@gmail.com>
Fri, 9 Aug 2013 01:07:37 +0000 (11:07 +1000)
commitd349b56e2d36282e464efac48e50b15c7fadda14
tree45668083bddf28253cb902a66e38dc93a59752ab
parent6f9090648a63dd428fae4d85856a9a455dd7a0b5
common/io: Keep queue buffer size multiple of 4K

Currently queue buffer size is realloc'd every time we need to extend the
buffer.  Small increments can cause memory fragmentation.  Instead always
extend buffer in multiples of 4K.  This should reduce multiple talloc_realloc
calls when there are lots of packets in the socket buffer.

Also, if queue buffer has grown larger than 64K, throw away the buffer once
all the requests in the queue have been processed.  That way queue does not
hold on to large buffers.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
(This used to be ctdb commit 5e9b1a7e24d058ff88aaa0563db36a804e866fa9)
ctdb/common/ctdb_io.c