render / rpms / libvirt

Forked from rpms/libvirt 11 months ago
Clone
a54075
From 00d63796318b065479eda661ab83503cc1cf8446 Mon Sep 17 00:00:00 2001
a54075
From: Martin Kletzander <mkletzan@redhat.com>
a54075
Date: Sun, 7 Sep 2014 17:08:57 +0200
a54075
Subject: [PATCH] rpc: reformat the flow to make a bit more sense
a54075
a54075
Just remove useless "else".  Best viewed with '-w'.
a54075
a54075
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
a54075
(cherry picked from commit 3951d4a6d3d5867eadc82814e8dd9a61d19b68cf)
a54075
---
a54075
 src/rpc/virnetsocket.c | 94 +++++++++++++++++++++++++-------------------------
a54075
 1 file changed, 47 insertions(+), 47 deletions(-)
a54075
a54075
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
a54075
index 9780e17..306c9ea 100644
a54075
--- a/src/rpc/virnetsocket.c
a54075
+++ b/src/rpc/virnetsocket.c
a54075
@@ -574,66 +574,66 @@ int virNetSocketNewConnectUNIX(const char *path,
a54075
 
a54075
  retry:
a54075
     if (connect(fd, &remoteAddr.data.sa, remoteAddr.len) < 0) {
a54075
+        int status = 0;
a54075
+        pid_t pid = 0;
a54075
+
a54075
         if (!spawnDaemon) {
a54075
             virReportSystemError(errno, _("Failed to connect socket to '%s'"),
a54075
                                  path);
a54075
             goto error;
a54075
-        } else {
a54075
-            int status = 0;
a54075
-            pid_t pid = 0;
a54075
-
a54075
-            if ((passfd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
a54075
-                virReportSystemError(errno, "%s", _("Failed to create socket"));
a54075
-                goto error;
a54075
-            }
a54075
+        }
a54075
 
a54075
-            /*
a54075
-             * We have to fork() here, because umask() is set
a54075
-             * per-process, chmod() is racy and fchmod() has undefined
a54075
-             * behaviour on sockets according to POSIX, so it doesn't
a54075
-             * work outside Linux.
a54075
-             */
a54075
-            if ((pid = virFork()) < 0)
a54075
-                goto error;
a54075
+        if ((passfd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
a54075
+            virReportSystemError(errno, "%s", _("Failed to create socket"));
a54075
+            goto error;
a54075
+        }
a54075
 
a54075
-            if (pid == 0) {
a54075
-                umask(0077);
a54075
-                if (bind(passfd, &remoteAddr.data.sa, remoteAddr.len) < 0)
a54075
-                    _exit(EXIT_FAILURE);
a54075
+        /*
a54075
+         * We have to fork() here, because umask() is set
a54075
+         * per-process, chmod() is racy and fchmod() has undefined
a54075
+         * behaviour on sockets according to POSIX, so it doesn't
a54075
+         * work outside Linux.
a54075
+         */
a54075
+        if ((pid = virFork()) < 0)
a54075
+            goto error;
a54075
 
a54075
-                _exit(EXIT_SUCCESS);
a54075
-            }
a54075
+        if (pid == 0) {
a54075
+            umask(0077);
a54075
+            if (bind(passfd, &remoteAddr.data.sa, remoteAddr.len) < 0)
a54075
+                _exit(EXIT_FAILURE);
a54075
 
a54075
-            if (virProcessWait(pid, &status, false) < 0)
a54075
-                goto error;
a54075
+            _exit(EXIT_SUCCESS);
a54075
+        }
a54075
 
a54075
-            if (status != EXIT_SUCCESS) {
a54075
-                /*
a54075
-                 * OK, so the subprocces failed to bind() the socket.  This may mean
a54075
-                 * that another daemon was starting at the same time and succeeded
a54075
-                 * with its bind().  So we'll try connecting again, but this time
a54075
-                 * without spawning the daemon.
a54075
-                 */
a54075
-                spawnDaemon = false;
a54075
-                goto retry;
a54075
-            }
a54075
+        if (virProcessWait(pid, &status, false) < 0)
a54075
+            goto error;
a54075
 
a54075
-            if (listen(passfd, 0) < 0) {
a54075
-                virReportSystemError(errno, "%s",
a54075
-                                     _("Failed to listen on socket that's about "
a54075
-                                       "to be passed to the daemon"));
a54075
-                goto error;
a54075
-            }
a54075
+        if (status != EXIT_SUCCESS) {
a54075
+            /*
a54075
+             * OK, so the subprocces failed to bind() the socket.  This may mean
a54075
+             * that another daemon was starting at the same time and succeeded
a54075
+             * with its bind().  So we'll try connecting again, but this time
a54075
+             * without spawning the daemon.
a54075
+             */
a54075
+            spawnDaemon = false;
a54075
+            goto retry;
a54075
+        }
a54075
 
a54075
-            if (connect(fd, &remoteAddr.data.sa, remoteAddr.len) < 0) {
a54075
-                virReportSystemError(errno, _("Failed to connect socket to '%s'"),
a54075
-                                     path);
a54075
-                goto error;
a54075
-            }
a54075
+        if (listen(passfd, 0) < 0) {
a54075
+            virReportSystemError(errno, "%s",
a54075
+                                 _("Failed to listen on socket that's about "
a54075
+                                   "to be passed to the daemon"));
a54075
+            goto error;
a54075
+        }
a54075
 
a54075
-            if (virNetSocketForkDaemon(binary, passfd) < 0)
a54075
-                goto error;
a54075
+        if (connect(fd, &remoteAddr.data.sa, remoteAddr.len) < 0) {
a54075
+            virReportSystemError(errno, _("Failed to connect socket to '%s'"),
a54075
+                                 path);
a54075
+            goto error;
a54075
         }
a54075
+
a54075
+        if (virNetSocketForkDaemon(binary, passfd) < 0)
a54075
+            goto error;
a54075
     }
a54075
 
a54075
     localAddr.len = sizeof(localAddr.data);