Ensure RPC message is cleared before being reused

To save on memory reallocation, virNetMessage instances that
have been transmitted, may be reused for a subsequent incoming
message. We forgot to clear out the old data of the message
fully, which caused later confusion upon read.

* src/rpc/virnetserverclient.c: memset entire message before
  reusing it
This commit is contained in:
Daniel P. Berrange 2011-06-30 12:26:54 +01:00
parent 27111b350f
commit d840fe93b0

View File

@ -837,6 +837,7 @@ virNetServerClientDispatchWrite(virNetServerClientPtr client)
client->nrequests < client->nrequests_max) {
/* Ready to recv more messages */
client->rx = msg;
memset(client->rx, 0, sizeof(*client->rx));
client->rx->bufferLength = VIR_NET_MESSAGE_LEN_MAX;
msg = NULL;
client->nrequests++;