]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
rpc: socket: Don't repeatedly attempt to launch daemon
authorCole Robinson <crobinso@redhat.com>
Tue, 12 Jan 2016 01:13:38 +0000 (20:13 -0500)
committerCole Robinson <crobinso@redhat.com>
Thu, 21 Jan 2016 00:10:30 +0000 (19:10 -0500)
On every socket connect(2) attempt we were re-launching session
libvirtd, up to 100 times in 5 seconds.

This understandably caused some weird load races and intermittent
qemu:///session startup failures

https://bugzilla.redhat.com/show_bug.cgi?id=1271183
(cherry picked from commit 2eb7a975756d05a5b54ab4acf60083beb6161ac6)

src/rpc/virnetsocket.c

index 90951be2f4183ecf0838b9da4c4e2365630528e9..2ee4b6ec2b92cc5930df6b883b1f216ec793d042 100644 (file)
@@ -547,6 +547,7 @@ int virNetSocketNewConnectUNIX(const char *path,
     virSocketAddr remoteAddr;
     char *rundir = NULL;
     int ret = -1;
+    bool daemonLaunched = false;
 
     VIR_DEBUG("path=%s spawnDaemon=%d binary=%s", path, spawnDaemon,
         NULLSTR(binary));
@@ -627,8 +628,12 @@ int virNetSocketNewConnectUNIX(const char *path,
             goto cleanup;
         }
 
-        if (virNetSocketForkDaemon(binary) < 0)
-            goto cleanup;
+        if (!daemonLaunched) {
+            if (virNetSocketForkDaemon(binary) < 0)
+                goto cleanup;
+
+            daemonLaunched = true;
+        }
 
         usleep(5000);
     }