mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 01:18:00 +03:00
rpc: Don't rewrite msg->fds on every read dispatch
When we are receiving data in smaller chunks it might happen that virNetServerClientDispatchRead() will be called multiple times. And as that happens, if it is a message that also transfer headers, we decode the number of them every single time and, unfortunately, also allocate the memory for them. That causes a leak, in the best scenario. Best viewed with '-w'. Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
545e5571f9
commit
133c511b52
@ -1107,7 +1107,8 @@ static void virNetServerClientDispatchRead(virNetServerClientPtr client)
|
||||
|
||||
/* Now figure out if we need to read more data to get some
|
||||
* file descriptors */
|
||||
if (msg->header.type == VIR_NET_CALL_WITH_FDS &&
|
||||
if (msg->header.type == VIR_NET_CALL_WITH_FDS) {
|
||||
if (msg->nfds == 0 &&
|
||||
virNetMessageDecodeNumFDs(msg) < 0) {
|
||||
virNetMessageQueueServe(&client->rx);
|
||||
virNetMessageFree(msg);
|
||||
@ -1138,6 +1139,7 @@ static void virNetServerClientDispatchRead(virNetServerClientPtr client)
|
||||
client->rx->bufferOffset = client->rx->bufferLength;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Definitely finished reading, so remove from queue */
|
||||
virNetMessageQueueServe(&client->rx);
|
||||
|
Loading…
Reference in New Issue
Block a user