]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
rpc: socket: Explicitly error if we exceed retry count
authorCole Robinson <crobinso@redhat.com>
Tue, 12 Jan 2016 01:08:45 +0000 (20:08 -0500)
committerCole Robinson <crobinso@redhat.com>
Thu, 21 Jan 2016 00:10:11 +0000 (19:10 -0500)
When we autolaunch libvirtd for session URIs, we spin in a retry
loop waiting for the daemon to start and the connect(2) to succeed.

However if we exceed the retry count, we don't explicitly raise an
error, which can yield a slew of different error messages elsewhere
in the code.

Explicitly raise the last connect(2) failure if we run out of retries.

(cherry picked from commit 8da02d528068942303923fc4f935e77cccac9c7c)

src/rpc/virnetsocket.c

index dcff69e5fd40734586bc7d8e1e884d87c242c18b..90951be2f4183ecf0838b9da4c4e2365630528e9 100644 (file)
@@ -618,7 +618,9 @@ int virNetSocketNewConnectUNIX(const char *path,
         }
         VIR_DEBUG("connect() failed: retries=%d errno=%d", retries, errno);
 
+        retries--;
         if (!spawnDaemon ||
+            retries == 0 ||
             (errno != ENOENT && errno != ECONNREFUSED)) {
             virReportSystemError(errno, _("Failed to connect socket to '%s'"),
                                  path);
@@ -628,7 +630,6 @@ int virNetSocketNewConnectUNIX(const char *path,
         if (virNetSocketForkDaemon(binary) < 0)
             goto cleanup;
 
-        retries--;
         usleep(5000);
     }