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

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

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

* 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

--
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]