mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
client rpc: Process pending data on error
Even though we hit an error in client's IO loop, we still want to process any pending data. So instead of reporting the error right away, we can finish the current iteration and report the error once we're done with it. Note that the error is stored in client->error by virNetClientMarkClose so we don't need to worry about it being reset or rewritten by any API we call in the meantime. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
c91776d5ff
commit
adf3be57df
@ -1460,6 +1460,7 @@ static int virNetClientIOEventLoop(virNetClientPtr client,
|
||||
virNetClientCallPtr thiscall)
|
||||
{
|
||||
struct pollfd fds[2];
|
||||
bool error = false;
|
||||
int ret;
|
||||
|
||||
fds[0].fd = virNetSocketGetFD(client->sock);
|
||||
@ -1551,10 +1552,11 @@ static int virNetClientIOEventLoop(virNetClientPtr client,
|
||||
if (virNetSocketHasCachedData(client->sock))
|
||||
fds[0].revents |= POLLIN;
|
||||
|
||||
/* If wantClose flag is set, pretend there was an error on the socket
|
||||
/* If wantClose flag is set, pretend there was an error on the socket,
|
||||
* but still read and process any data we received so far.
|
||||
*/
|
||||
if (client->wantClose)
|
||||
fds[0].revents = POLLERR;
|
||||
error = true;
|
||||
|
||||
if (fds[1].revents) {
|
||||
VIR_DEBUG("Woken up from poll by other thread");
|
||||
@ -1562,21 +1564,24 @@ static int virNetClientIOEventLoop(virNetClientPtr client,
|
||||
virReportSystemError(errno, "%s",
|
||||
_("read on wakeup fd failed"));
|
||||
virNetClientMarkClose(client, VIR_CONNECT_CLOSE_REASON_ERROR);
|
||||
goto error;
|
||||
error = true;
|
||||
/* Fall through to process any pending data. */
|
||||
}
|
||||
}
|
||||
|
||||
if (fds[0].revents & POLLOUT) {
|
||||
if (virNetClientIOHandleOutput(client) < 0) {
|
||||
virNetClientMarkClose(client, VIR_CONNECT_CLOSE_REASON_ERROR);
|
||||
goto error;
|
||||
error = true;
|
||||
/* Fall through to process any pending data. */
|
||||
}
|
||||
}
|
||||
|
||||
if (fds[0].revents & POLLIN) {
|
||||
if (virNetClientIOHandleInput(client) < 0) {
|
||||
virNetClientMarkClose(client, VIR_CONNECT_CLOSE_REASON_ERROR);
|
||||
goto error;
|
||||
error = true;
|
||||
/* Fall through to process any pending data. */
|
||||
}
|
||||
}
|
||||
|
||||
@ -1601,6 +1606,9 @@ static int virNetClientIOEventLoop(virNetClientPtr client,
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (error)
|
||||
goto error;
|
||||
|
||||
if (fds[0].revents & (POLLHUP | POLLERR)) {
|
||||
virNetClientMarkClose(client, VIR_CONNECT_CLOSE_REASON_EOF);
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
|
Loading…
x
Reference in New Issue
Block a user