Refactor code for enabling/disabling I/O callback in remote client

* src/rpc/virnetclient.c: Add helper for setting I/O callback events
This commit is contained in:
Daniel P. Berrange 2011-11-11 15:45:44 +00:00
parent 5990f227e9
commit b196220337

View File

@ -1176,6 +1176,17 @@ error:
}
static void virNetClientIOUpdateCallback(virNetClientPtr client,
bool enableCallback)
{
int events = 0;
if (enableCallback)
events |= VIR_EVENT_HANDLE_READABLE;
virNetSocketUpdateIOCallback(client->sock, events);
}
/*
* This function sends a message to remote server and awaits a reply
*
@ -1284,12 +1295,12 @@ static int virNetClientIO(virNetClientPtr client,
* cause the event loop thread to be blocked on the
* mutex for the duration of the call
*/
virNetSocketUpdateIOCallback(client->sock, 0);
virNetClientIOUpdateCallback(client, false);
virResetLastError();
rv = virNetClientIOEventLoop(client, thiscall);
virNetSocketUpdateIOCallback(client->sock, VIR_EVENT_HANDLE_READABLE);
virNetClientIOUpdateCallback(client, true);
if (rv == 0 &&
virGetLastError())