render / rpms / libvirt

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