
On 3/4/22 18:28, Tim Wiederhake wrote:
Signed-off-by: Tim Wiederhake <twiederh@redhat.com> --- src/remote/remote_daemon_dispatch.c | 187 +++++++++------------------- 1 file changed, 58 insertions(+), 129 deletions(-)
diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c index 510856024c..1a73976831 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -2057,14 +2057,13 @@ remoteDispatchConnectOpen(virNetServer *server G_GNUC_UNUSED, #endif unsigned int flags; struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client); - int rv = -1; #ifdef MODULE_NAME const char *type = NULL; #endif /* !MODULE_NAME */ bool preserveIdentity = false; + VIR_LOCK_GUARD lock = virLockGuardLock(&priv->lock);
VIR_DEBUG("priv=%p conn=%p", priv, priv->conn); - virMutexLock(&priv->lock); /* Already opened? */ if (priv->conn) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection already open")); @@ -2184,17 +2183,14 @@ remoteDispatchConnectOpen(virNetServer *server G_GNUC_UNUSED, * by default, but do accept RO flags, e.g. TCP */ virNetServerClientSetReadonly(client, (flags & VIR_CONNECT_RO)); - rv = 0; + return 0;
cleanup:
Here, and in the rest of the patch: This label is now used only in case of failure, so it should be renamed to 'error'. But it's okay to do that in a follow up patch.
- if (rv < 0) { - virNetMessageSaveError(rerr); - if (priv->conn) { - g_clear_pointer(&priv->conn, virObjectUnref); - } + virNetMessageSaveError(rerr); + if (priv->conn) { + g_clear_pointer(&priv->conn, virObjectUnref); } - virMutexUnlock(&priv->lock); - return rv; + return -1; }
Michal