Richard W.M. Jones
2021-Aug-09 19:14 UTC
[Libguestfs] [PATCH nbdkit] server: Return from nbdkit_nanosleep early if the socket closes
https://bugzilla.redhat.com/show_bug.cgi?id=1991652#c2
Reported-by: Ming Xie
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1991652
---
server/public.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/server/public.c b/server/public.c
index 3362f1ab..30fb5aa0 100644
--- a/server/public.c
+++ b/server/public.c
@@ -693,6 +693,8 @@ nbdkit_nanosleep (unsigned sec, unsigned nsec)
* - the current connection is multi-threaded and another thread detects
* NBD_CMD_DISC or a problem with the connection
* - the input socket detects POLLRDHUP/POLLHUP/POLLERR
+ * - the input socket is invalid (POLLNVAL, probably closed by
+ * another thread)
*/
struct connection *conn = threadlocal_get_conn ();
struct pollfd fds[] = {
@@ -724,7 +726,8 @@ nbdkit_nanosleep (unsigned sec, unsigned nsec)
*/
assert (quit ||
(conn && conn->nworkers > 0 &&
connection_get_status () < 1) ||
- (conn && (fds[2].revents & (POLLRDHUP | POLLHUP |
POLLERR))));
+ (conn && (fds[2].revents & (POLLRDHUP | POLLHUP |
+ POLLERR | POLLNVAL))));
nbdkit_error ("aborting sleep to shut down");
errno = ESHUTDOWN;
return -1;
--
2.32.0
Eric Blake
2021-Aug-09 19:27 UTC
[Libguestfs] [PATCH nbdkit] server: Return from nbdkit_nanosleep early if the socket closes
On Mon, Aug 09, 2021 at 08:14:51PM +0100, Richard W.M. Jones wrote:> https://bugzilla.redhat.com/show_bug.cgi?id=1991652#c2 > > Reported-by: Ming Xie > Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1991652 > --- > server/public.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-)ACK. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org