mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 19:45:21 +00:00
Process all pending I/O for a RPC client before checking EOF
In the socket event handler for the RPC client we must deal with read/write events, before checking for EOF, otherwise we might close the socket before we've read & acted upon the last RPC messages Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
0998cdae70
commit
b536e193a2
@ -1694,16 +1694,6 @@ void virNetClientIncomingEvent(virNetSocketPtr sock,
|
||||
|
||||
VIR_DEBUG("Event fired %p %d", sock, events);
|
||||
|
||||
if (events & (VIR_EVENT_HANDLE_HANGUP | VIR_EVENT_HANDLE_ERROR)) {
|
||||
VIR_DEBUG("%s : VIR_EVENT_HANDLE_HANGUP or "
|
||||
"VIR_EVENT_HANDLE_ERROR encountered", __FUNCTION__);
|
||||
virNetClientMarkClose(client,
|
||||
(events & VIR_EVENT_HANDLE_HANGUP) ?
|
||||
VIR_CONNECT_CLOSE_REASON_EOF :
|
||||
VIR_CONNECT_CLOSE_REASON_ERROR);
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (events & VIR_EVENT_HANDLE_WRITABLE) {
|
||||
if (virNetClientIOHandleOutput(client) < 0)
|
||||
virNetClientMarkClose(client, VIR_CONNECT_CLOSE_REASON_ERROR);
|
||||
@ -1714,6 +1704,16 @@ void virNetClientIncomingEvent(virNetSocketPtr sock,
|
||||
virNetClientMarkClose(client, VIR_CONNECT_CLOSE_REASON_ERROR);
|
||||
}
|
||||
|
||||
if (events & (VIR_EVENT_HANDLE_HANGUP | VIR_EVENT_HANDLE_ERROR)) {
|
||||
VIR_DEBUG("VIR_EVENT_HANDLE_HANGUP or "
|
||||
"VIR_EVENT_HANDLE_ERROR encountered");
|
||||
virNetClientMarkClose(client,
|
||||
(events & VIR_EVENT_HANDLE_HANGUP) ?
|
||||
VIR_CONNECT_CLOSE_REASON_EOF :
|
||||
VIR_CONNECT_CLOSE_REASON_ERROR);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Remove completed calls or signal their threads. */
|
||||
virNetClientCallRemovePredicate(&client->waitDispatch,
|
||||
virNetClientIOEventLoopRemoveDone,
|
||||
|
Loading…
Reference in New Issue
Block a user