[libvirt] [PATCH 5/9] Move queuing of RPC replies into dispatch code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 qemud/dispatch.c |    6 ++++++
 qemud/qemud.c    |   16 +++++-----------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/qemud/dispatch.c b/qemud/dispatch.c
index 29970e4..ce8dbc9 100644
--- a/qemud/dispatch.c
+++ b/qemud/dispatch.c
@@ -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:
diff --git a/qemud/qemud.c b/qemud/qemud.c
index c577d88..4952d0b 100644
--- a/qemud/qemud.c
+++ b/qemud/qemud.c
@@ -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);
 
-- 
1.6.2.5


-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]