rpc: socket: Explicitly error if we exceed retry count

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.
This commit is contained in:
Cole Robinson 2016-01-11 20:08:45 -05:00
parent f102c7146e
commit 8da02d5280
1 changed files with 2 additions and 1 deletions

View File

@ -690,7 +690,9 @@ int virNetSocketNewConnectUNIX(const char *path,
} }
VIR_DEBUG("connect() failed: retries=%d errno=%d", retries, errno); VIR_DEBUG("connect() failed: retries=%d errno=%d", retries, errno);
retries--;
if (!spawnDaemon || if (!spawnDaemon ||
retries == 0 ||
(errno != ENOENT && errno != ECONNREFUSED)) { (errno != ENOENT && errno != ECONNREFUSED)) {
virReportSystemError(errno, _("Failed to connect socket to '%s'"), virReportSystemError(errno, _("Failed to connect socket to '%s'"),
path); path);
@ -700,7 +702,6 @@ int virNetSocketNewConnectUNIX(const char *path,
if (virNetSocketForkDaemon(binary) < 0) if (virNetSocketForkDaemon(binary) < 0)
goto cleanup; goto cleanup;
retries--;
usleep(5000); usleep(5000);
} }