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

[libvirt] [PATCH 5/6] Refactor code for enabling/disabling I/O callback in remote client



From: "Daniel P. Berrange" <berrange redhat com>

* src/rpc/virnetclient.c: Add helper for setting I/O callback events
---
 src/rpc/virnetclient.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index c4136b4..96d1886 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -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())
-- 
1.7.6.4


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