From 032531cd5d402119a81efbaf07d781123c5b02af Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Tue, 10 Aug 2021 08:30:43 +0100 Subject: [PATCH] server: nanosleep: Change error for early end of sleep At the moment nbdkit_nanosleep gives an incorrect error message if it aborts early. Even in the case when the server is not actually shutting down it will say: $ nbdkit --filter=delay null delay-close=3 --run 'nbdinfo --size $uri; nbdinfo --size $uri' 0 nbdkit: null[1]: error: aborting sleep to shut down 0 nbdkit: null[2]: error: aborting sleep to shut down This commit changes the error so we only talk about shut down when the server is actually shutting down, and use a different message in other cases. (cherry picked from commit cd24d9c418992e6f2c721c7deec70e564c23ab83) --- server/public.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/public.c b/server/public.c index 4870e2d3..d9ed0d9c 100644 --- a/server/public.c +++ b/server/public.c @@ -728,7 +728,10 @@ nbdkit_nanosleep (unsigned sec, unsigned nsec) (conn && conn->nworkers > 0 && connection_get_status () < 1) || (conn && (fds[2].revents & (POLLRDHUP | POLLHUP | POLLERR | POLLNVAL)))); - nbdkit_error ("aborting sleep to shut down"); + if (quit) + nbdkit_error ("aborting sleep because of server shut down"); + else + nbdkit_error ("aborting sleep because of connection close or error"); errno = ESHUTDOWN; return -1; -- 2.31.1