The helper splits out the clearing of the FDs transacted inside a virNetMessage. APIs transacting FDs both from and to the client at the same time will need to clear the FDs stored in virNetMessage as the structure is re-used for the reply and without clearing the list of FDs we'd return the FDs sent by the client in addition to the new FDs sent by the API.t Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/libvirt_remote.syms | 1 + src/rpc/virnetmessage.c | 9 ++++++++- src/rpc/virnetmessage.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/libvirt_remote.syms b/src/libvirt_remote.syms index 2fa46e5e0c..f0f90815cf 100644 --- a/src/libvirt_remote.syms +++ b/src/libvirt_remote.syms @@ -102,6 +102,7 @@ virNetDaemonUpdateServices; # rpc/virnetmessage.h virNetMessageAddFD; virNetMessageClear; +virNetMessageClearFDs; virNetMessageClearPayload; virNetMessageDecodeHeader; virNetMessageDecodeLength; diff --git a/src/rpc/virnetmessage.c b/src/rpc/virnetmessage.c index ca11f1688e..221da7c59b 100644 --- a/src/rpc/virnetmessage.c +++ b/src/rpc/virnetmessage.c @@ -48,7 +48,7 @@ virNetMessage *virNetMessageNew(bool tracked) void -virNetMessageClearPayload(virNetMessage *msg) +virNetMessageClearFDs(virNetMessage *msg) { size_t i; @@ -58,6 +58,13 @@ virNetMessageClearPayload(virNetMessage *msg) msg->donefds = 0; msg->nfds = 0; VIR_FREE(msg->fds); +} + + +void +virNetMessageClearPayload(virNetMessage *msg) +{ + virNetMessageClearFDs(msg); msg->bufferOffset = 0; msg->bufferLength = 0; diff --git a/src/rpc/virnetmessage.h b/src/rpc/virnetmessage.h index aadf1b69b0..8f878962f8 100644 --- a/src/rpc/virnetmessage.h +++ b/src/rpc/virnetmessage.h @@ -49,6 +49,7 @@ struct _virNetMessage { virNetMessage *virNetMessageNew(bool tracked); +void virNetMessageClearFDs(virNetMessage *msg); void virNetMessageClearPayload(virNetMessage *msg); void virNetMessageClear(virNetMessage *); -- 2.35.1