]> xenbits.xensource.com Git - libvirt.git/commitdiff
remote: Move the call to remoteClientFreePrivateCallbacks from FreeFunc to CloseFunc
authorxinhua.Cao <caoxinhua@huawei.com>
Mon, 13 Nov 2017 13:07:58 +0000 (21:07 +0800)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 23 Nov 2017 13:00:34 +0000 (08:00 -0500)
Still because of commit id 'fe8f1c8b' where we generate a REF for the
Register and that's transparent to the consumer (e.g. how would they
know they need to ensure that Deregister is called), thus the purpose of
this patch is to find a way to Deregister if it's determined that the
consumer hasn't by the time of the "last" REF we'd have.

This solution to this problem is to alter the processing to have the
remoteClientCloseFunc handle performing the Deregister calls instead of
the remoteClientFreeFunc because there's no way FreeFunc would be called
unless the Deregister was already called.

daemon/remote.c

index 2dcec1ea5ac060ec1f8c83d06c00196d763682bd..c2111ae378a266db19639097f2b6853a5d006806 100644 (file)
@@ -1738,11 +1738,9 @@ void remoteClientFreeFunc(void *data)
 {
     struct daemonClientPrivate *priv = data;
 
-    /* Deregister event delivery callback */
-    if (priv->conn) {
-        remoteClientFreePrivateCallbacks(priv);
+    if (priv->conn)
         virConnectClose(priv->conn);
-    }
+
     VIR_FREE(priv);
 }
 
@@ -1752,6 +1750,10 @@ static void remoteClientCloseFunc(virNetServerClientPtr client)
     struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client);
 
     daemonRemoveAllClientStreams(priv->streams);
+
+    /* Deregister event delivery callback */
+    if (priv->conn)
+        remoteClientFreePrivateCallbacks(priv);
 }