提交 c40e14b4 编写于 作者: D Daniel P. Berrange

Move queuing of RPC replies into dispatch code

This removes an assumption from qemudWorker() code that every
incoming message will generate a reply.

* qemud/dispatch.c: remoteDispatchClientRequest now has responsibility
  for queuing the reply message to the RPC call
* qemud/qemud.c: Do not queue the RPC call reply in qemudWorker(),
  allowing remoteDispatchClientRequest() to take care of it
上级 aa23d432
......@@ -387,6 +387,12 @@ rpc_error:
msg->bufferLength = len;
msg->bufferOffset = 0;
/* Put reply on end of tx queue to send out */
qemudClientMessageQueuePush(&client->tx, msg);
if (qemudRegisterClientEvent(server, client, 1) < 0)
qemudDispatchClientFailure(client);
return 0;
fatal_error:
......
......@@ -1431,7 +1431,7 @@ static void *qemudWorker(void *data)
while (1) {
struct qemud_client *client = NULL;
struct qemud_client_message *reply;
struct qemud_client_message *msg;
virMutexLock(&server->lock);
while (((client = qemudPendingJob(server)) == NULL) &&
......@@ -1454,25 +1454,19 @@ static void *qemudWorker(void *data)
client->refs++;
/* Remove our message from dispatch queue while we use it */
reply = qemudClientMessageQueueServe(&client->dx);
msg = qemudClientMessageQueueServe(&client->dx);
/* This function drops the lock during dispatch,
* and re-acquires it before returning */
if (remoteDecodeClientMessageHeader(reply) < 0 ||
remoteDispatchClientRequest (server, client, reply) < 0) {
VIR_FREE(reply);
if (remoteDecodeClientMessageHeader(msg) < 0 ||
remoteDispatchClientRequest (server, client, msg) < 0) {
VIR_FREE(msg);
qemudDispatchClientFailure(client);
client->refs--;
virMutexUnlock(&client->lock);
continue;
}
/* Put reply on end of tx queue to send out */
qemudClientMessageQueuePush(&client->tx, reply);
if (qemudRegisterClientEvent(server, client, 1) < 0)
qemudDispatchClientFailure(client);
client->refs--;
virMutexUnlock(&client->lock);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册