[libvirt] [PATCH libvirt v2 9/9] remote: shrink the critical sections

Marc Hartmayer mhartmay at linux.vnet.ibm.com
Thu Apr 12 12:41:04 UTC 2018


No lock is required to access 'priv->conn' therefore we can shrink the
critical sections.

Signed-off-by: Marc Hartmayer <mhartmay at linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy at linux.ibm.com>
---
 src/remote/remote_daemon_dispatch.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
index 041e7c7440bf..d6699418392e 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -3841,8 +3841,6 @@ remoteDispatchConnectRegisterCloseCallback(virNetServerPtr server,
         virNetServerClientGetPrivateData(client);
     virNetServerProgramPtr program;
 
-    virMutexLock(&priv->lock);
-
     if (!priv->conn) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
@@ -3853,6 +3851,8 @@ remoteDispatchConnectRegisterCloseCallback(virNetServerPtr server,
         goto cleanup;
     }
 
+    virMutexLock(&priv->lock);
+
     if (VIR_ALLOC(callback) < 0)
         goto cleanup;
     callback->client = virObjectRef(client);
@@ -3887,13 +3887,13 @@ remoteDispatchConnectUnregisterCloseCallback(virNetServerPtr server ATTRIBUTE_UN
     struct daemonClientPrivate *priv =
         virNetServerClientGetPrivateData(client);
 
-    virMutexLock(&priv->lock);
-
     if (!priv->conn) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
         goto cleanup;
     }
 
+    virMutexLock(&priv->lock);
+
     if (virConnectUnregisterCloseCallback(priv->conn,
                                           remoteRelayConnectionClosedEvent) < 0)
         goto cleanup;
-- 
2.13.4




More information about the libvir-list mailing list