提交 aef963f1 编写于 作者: M Martin Kletzander 提交者: Eric Blake

rpc: reformat the flow to make a bit more sense

Just remove useless "else".  Best viewed with '-w'.
Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
(cherry picked from commit 3951d4a6)
上级 f6f9edf1
...@@ -574,66 +574,66 @@ int virNetSocketNewConnectUNIX(const char *path, ...@@ -574,66 +574,66 @@ int virNetSocketNewConnectUNIX(const char *path,
retry: retry:
if (connect(fd, &remoteAddr.data.sa, remoteAddr.len) < 0) { if (connect(fd, &remoteAddr.data.sa, remoteAddr.len) < 0) {
int status = 0;
pid_t pid = 0;
if (!spawnDaemon) { if (!spawnDaemon) {
virReportSystemError(errno, _("Failed to connect socket to '%s'"), virReportSystemError(errno, _("Failed to connect socket to '%s'"),
path); path);
goto error; goto error;
} else { }
int status = 0;
pid_t pid = 0;
if ((passfd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
virReportSystemError(errno, "%s", _("Failed to create socket"));
goto error;
}
/* if ((passfd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
* We have to fork() here, because umask() is set virReportSystemError(errno, "%s", _("Failed to create socket"));
* per-process, chmod() is racy and fchmod() has undefined goto error;
* behaviour on sockets according to POSIX, so it doesn't }
* work outside Linux.
*/
if ((pid = virFork()) < 0)
goto error;
if (pid == 0) { /*
umask(0077); * We have to fork() here, because umask() is set
if (bind(passfd, &remoteAddr.data.sa, remoteAddr.len) < 0) * per-process, chmod() is racy and fchmod() has undefined
_exit(EXIT_FAILURE); * behaviour on sockets according to POSIX, so it doesn't
* work outside Linux.
*/
if ((pid = virFork()) < 0)
goto error;
_exit(EXIT_SUCCESS); if (pid == 0) {
} umask(0077);
if (bind(passfd, &remoteAddr.data.sa, remoteAddr.len) < 0)
_exit(EXIT_FAILURE);
if (virProcessWait(pid, &status, false) < 0) _exit(EXIT_SUCCESS);
goto error; }
if (status != EXIT_SUCCESS) { if (virProcessWait(pid, &status, false) < 0)
/* goto error;
* OK, so the subprocces failed to bind() the socket. This may mean
* that another daemon was starting at the same time and succeeded
* with its bind(). So we'll try connecting again, but this time
* without spawning the daemon.
*/
spawnDaemon = false;
goto retry;
}
if (listen(passfd, 0) < 0) { if (status != EXIT_SUCCESS) {
virReportSystemError(errno, "%s", /*
_("Failed to listen on socket that's about " * OK, so the subprocces failed to bind() the socket. This may mean
"to be passed to the daemon")); * that another daemon was starting at the same time and succeeded
goto error; * with its bind(). So we'll try connecting again, but this time
} * without spawning the daemon.
*/
spawnDaemon = false;
goto retry;
}
if (connect(fd, &remoteAddr.data.sa, remoteAddr.len) < 0) { if (listen(passfd, 0) < 0) {
virReportSystemError(errno, _("Failed to connect socket to '%s'"), virReportSystemError(errno, "%s",
path); _("Failed to listen on socket that's about "
goto error; "to be passed to the daemon"));
} goto error;
}
if (virNetSocketForkDaemon(binary, passfd) < 0) if (connect(fd, &remoteAddr.data.sa, remoteAddr.len) < 0) {
goto error; virReportSystemError(errno, _("Failed to connect socket to '%s'"),
path);
goto error;
} }
if (virNetSocketForkDaemon(binary, passfd) < 0)
goto error;
} }
localAddr.len = sizeof(localAddr.data); localAddr.len = sizeof(localAddr.data);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册