passt: Don't fork into background until the UNIX domain socket isn't listening
Once passt forks to background, it should be guaranteed that the UNIX domain socket is available, otherwise, if qemu is started right after it, it might fail to connect. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
6f89dc3650
commit
0328e2a1f7
1 changed files with 7 additions and 4 deletions
11
passt.c
11
passt.c
|
@ -757,10 +757,6 @@ int main(int argc, char **argv)
|
|||
openlog("passt", LOG_PERROR, LOG_DAEMON);
|
||||
#else
|
||||
openlog("passt", 0, LOG_DAEMON);
|
||||
if (daemon(0, 0)) {
|
||||
fprintf(stderr, "Failed to fork into background\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#endif
|
||||
|
||||
get_routes(&c);
|
||||
|
@ -812,6 +808,13 @@ listen:
|
|||
info(" kvm ... -net socket,connect="
|
||||
UNIX_SOCK_PATH " -net nic,model=virtio");
|
||||
|
||||
#ifndef DEBUG
|
||||
if (daemon(0, 0)) {
|
||||
fprintf(stderr, "Failed to fork into background\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#endif
|
||||
|
||||
c.fd_unix = accept(fd_unix, NULL, NULL);
|
||||
ev.events = EPOLLIN | EPOLLRDHUP | EPOLLERR | EPOLLHUP;
|
||||
ev.data.fd = c.fd_unix;
|
||||
|
|
Loading…
Reference in a new issue