[PATCH v2 2/8] remote: push check for conn down into remoteClientFreePrivateCallbacks

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

 



There will shortly be many connection objects, so we should not assume a
single check against priv->conn is sufficient.

Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---
 src/remote/remote_daemon_dispatch.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
index 121d114ae3..853e63901b 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -1673,6 +1673,11 @@ void remoteRelayConnectionClosedEvent(virConnectPtr conn ATTRIBUTE_UNUSED, int r
 #define DEREG_CB(conn, eventCallbacks, neventCallbacks, deregFcn, name) \
     do { \
         size_t i; \
+        if (neventCallbacks && !conn) { \
+            VIR_WARN("Have %zu %s event callbacks but no connection", \
+                     neventCallbacks, name); \
+            break; \
+        } \
         for (i = 0; i < neventCallbacks; i++) { \
             int callbackID = eventCallbacks[i]->callbackID; \
             if (callbackID < 0) { \
@@ -1715,7 +1720,7 @@ remoteClientFreePrivateCallbacks(struct daemonClientPrivate *priv)
              priv->nqemuEventCallbacks,
              virConnectDomainQemuMonitorEventDeregister, "qemu monitor");
 
-    if (priv->closeRegistered) {
+    if (priv->closeRegistered && priv->conn) {
         if (virConnectUnregisterCloseCallback(priv->conn,
                                               remoteRelayConnectionClosedEvent) < 0)
             VIR_WARN("unexpected close callback event deregister failure");
@@ -1751,9 +1756,7 @@ static void remoteClientCloseFunc(virNetServerClientPtr client)
 
     daemonRemoveAllClientStreams(priv->streams);
 
-    /* Deregister event delivery callback */
-    if (priv->conn)
-        remoteClientFreePrivateCallbacks(priv);
+    remoteClientFreePrivateCallbacks(priv);
 }
 
 
-- 
2.14.3

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

  Powered by Linux