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

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

 



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

Signed-off-by: Marc Hartmayer <mhartmay@xxxxxxxxxxxxxxxxxx>
Reviewed-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxx>
---
 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

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