aboutgitcodebugslistschat
path: root/passt.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-01-26 16:39:33 +0100
committerStefano Brivio <sbrivio@redhat.com>2022-01-28 18:51:50 +0100
commit34e642923538a05ac21d7e7495da23fb0da56c5f (patch)
tree7bf87c1259114dd95d05302d9fdc9aa985edbab7 /passt.c
parentb1f5688495665269fb17732a3c7fb91c709e61b6 (diff)
downloadpasst-34e642923538a05ac21d7e7495da23fb0da56c5f.tar
passt-34e642923538a05ac21d7e7495da23fb0da56c5f.tar.gz
passt-34e642923538a05ac21d7e7495da23fb0da56c5f.tar.bz2
passt-34e642923538a05ac21d7e7495da23fb0da56c5f.tar.lz
passt-34e642923538a05ac21d7e7495da23fb0da56c5f.tar.xz
passt-34e642923538a05ac21d7e7495da23fb0da56c5f.tar.zst
passt-34e642923538a05ac21d7e7495da23fb0da56c5f.zip
passt, tap: Daemonise once socket is ready without waiting for connection
The existing behaviour is not really practical: an automated agent in charge of starting both qemu and passt would need to fork itself to start passt, because passt won't fork to background until qemu connects, and the agent needs to unblock to start qemu. Instead of waiting for a connection to daemonise, do it right away as soon as a socket is available: that can be considered an initialised state already. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'passt.c')
-rw-r--r--passt.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/passt.c b/passt.c
index 3c9fb90..a8bb88e 100644
--- a/passt.c
+++ b/passt.c
@@ -345,6 +345,7 @@ int main(int argc, char **argv)
}
sock_probe_mem(&c);
+ c.fd_tap = c.fd_tap_listen = -1;
tap_sock_init(&c);
clock_gettime(CLOCK_MONOTONIC, &now);
@@ -387,9 +388,10 @@ loop:
for (i = 0; i < nfds; i++) {
union epoll_ref ref = *((union epoll_ref *)&events[i].data.u64);
+ int fd = events[i].data.fd;
- if (events[i].data.fd == c.fd_tap)
- tap_handler(&c, events[i].events, &now);
+ if (fd == c.fd_tap || fd == c.fd_tap_listen)
+ tap_handler(&c, fd, events[i].events, &now);
else
sock_handler(&c, ref, events[i].events, &now);
}