mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 21:34:54 +03:00
rpc: use virNetMessageClearPayload in client
This removes the opencoded payload freeing in the client, to use the shared virNetMessageClearPayload call. Two changes: - ClearPayload sets nfds=0, which fixes a potential crash if an error path called virNetMessageFree/Clear on the message after fds was free'd - We drop the inner loop VIR_FORCE_CLOSE... this may mean fds are kept open a little bit longer if the call is blocking but in practice I don't think it will have any effect
This commit is contained in:
parent
64bd680d42
commit
b6238738ea
@ -79,6 +79,7 @@ virNetDaemonUpdateServices;
|
||||
|
||||
# rpc/virnetmessage.h
|
||||
virNetMessageClear;
|
||||
virNetMessageClearPayload;
|
||||
virNetMessageDecodeHeader;
|
||||
virNetMessageDecodeLength;
|
||||
virNetMessageDecodeNumFDs;
|
||||
|
@ -1194,12 +1194,8 @@ virNetClientIOWriteMessage(virNetClientPtr client,
|
||||
if (rv == 0) /* Blocking */
|
||||
return 0;
|
||||
thecall->msg->donefds++;
|
||||
VIR_FORCE_CLOSE(thecall->msg->fds[i]);
|
||||
}
|
||||
thecall->msg->donefds = 0;
|
||||
thecall->msg->bufferOffset = thecall->msg->bufferLength = 0;
|
||||
VIR_FREE(thecall->msg->fds);
|
||||
VIR_FREE(thecall->msg->buffer);
|
||||
virNetMessageClearPayload(thecall->msg);
|
||||
if (thecall->expectReply)
|
||||
thecall->mode = VIR_NET_CLIENT_MODE_WAIT_RX;
|
||||
else
|
||||
|
@ -49,7 +49,7 @@ virNetMessagePtr virNetMessageNew(bool tracked)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
void
|
||||
virNetMessageClearPayload(virNetMessagePtr msg)
|
||||
{
|
||||
size_t i;
|
||||
|
@ -54,6 +54,8 @@ struct _virNetMessage {
|
||||
|
||||
virNetMessagePtr virNetMessageNew(bool tracked);
|
||||
|
||||
void virNetMessageClearPayload(virNetMessagePtr msg);
|
||||
|
||||
void virNetMessageClear(virNetMessagePtr);
|
||||
|
||||
void virNetMessageFree(virNetMessagePtr msg);
|
||||
|
Loading…
Reference in New Issue
Block a user