MachMessageServer: handle allocations more reasonably.
MachMessageServer: handle allocations more reasonably.

MachMessageServer was wasteful with allocations for request and reply
messages. It allocated new memory for each request receive and for each
reply send, and if it needed to resize an allocation for a request, it
would maintain two request allocations simultaneously. The new behavior
allocates memory for a new request only if it needs a different size
than for the previous request, and it never maintains two request
allocations simultaneously. Memory for a reply is allocated once per
method invocation and maintained, since this never needs to be resized.

One pass of the loop is now guaranteed, even if a caller specifies a
very small timeout that expires before attempting to receive a message.

An infinite looping bug that could occur when ignoring large messages
has also been fixed.

TEST=util_test MachMessageServer.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/759023004

hankbao/Crashpad,Chilledheart/crashpad,Chilledheart/crashpad,atom/crashpad,chromium/crashpad,chromium/crashpad,hokein/crashpad,Chilledheart/crashpad,hokein/crashpad,atom/crashpad,hokein/crashpad,hankbao/Crashpad,hankbao/Crashpad,chromium/crashpad,atom/crashpad