mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Refactor code for passing the buck in the remote client
Remove some duplication by pulling the code for passing the buck out into a helper method * src/rpc/virnetclient.c: Introduce virNetClientIOEventLoopPassTheBuck
This commit is contained in:
parent
fa9595003d
commit
9f28ad0026
@ -1025,6 +1025,23 @@ static bool virNetClientIOEventLoopRemoveDone(virNetClientCallPtr call,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void virNetClientIOEventLoopPassTheBuck(virNetClientPtr client, virNetClientCallPtr thiscall)
|
||||||
|
{
|
||||||
|
VIR_DEBUG("Giving up the buck %p", thiscall);
|
||||||
|
virNetClientCallPtr tmp = client->waitDispatch;
|
||||||
|
/* See if someone else is still waiting
|
||||||
|
* and if so, then pass the buck ! */
|
||||||
|
while (tmp) {
|
||||||
|
if (tmp != thiscall) {
|
||||||
|
VIR_DEBUG("Passing the buck to %p", tmp);
|
||||||
|
virCondSignal(&tmp->cond);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
tmp = tmp->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Process all calls pending dispatch/receive until we
|
* Process all calls pending dispatch/receive until we
|
||||||
* get a reply to our own call. Then quit and pass the buck
|
* get a reply to our own call. Then quit and pass the buck
|
||||||
@ -1139,15 +1156,7 @@ static int virNetClientIOEventLoop(virNetClientPtr client,
|
|||||||
/* Now see if *we* are done */
|
/* Now see if *we* are done */
|
||||||
if (thiscall->mode == VIR_NET_CLIENT_MODE_COMPLETE) {
|
if (thiscall->mode == VIR_NET_CLIENT_MODE_COMPLETE) {
|
||||||
virNetClientCallRemove(&client->waitDispatch, thiscall);
|
virNetClientCallRemove(&client->waitDispatch, thiscall);
|
||||||
|
virNetClientIOEventLoopPassTheBuck(client, thiscall);
|
||||||
VIR_DEBUG("Giving up the buck %p %p", thiscall, client->waitDispatch);
|
|
||||||
|
|
||||||
/* See if someone else is still waiting
|
|
||||||
* and if so, then pass the buck ! */
|
|
||||||
if (client->waitDispatch) {
|
|
||||||
VIR_DEBUG("Passing the buck to %p", client->waitDispatch);
|
|
||||||
virCondSignal(&client->waitDispatch->cond);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1162,13 +1171,7 @@ static int virNetClientIOEventLoop(virNetClientPtr client,
|
|||||||
|
|
||||||
error:
|
error:
|
||||||
virNetClientCallRemove(&client->waitDispatch, thiscall);
|
virNetClientCallRemove(&client->waitDispatch, thiscall);
|
||||||
VIR_DEBUG("Giving up the buck due to I/O error %p %p", thiscall, client->waitDispatch);
|
virNetClientIOEventLoopPassTheBuck(client, thiscall);
|
||||||
/* See if someone else is still waiting
|
|
||||||
* and if so, then pass the buck ! */
|
|
||||||
if (client->waitDispatch) {
|
|
||||||
VIR_DEBUG("Passing the buck to %p", client->waitDispatch);
|
|
||||||
virCondSignal(&client->waitDispatch->cond);
|
|
||||||
}
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user