[Libguestfs] [nbdkit PATCH 2/6] connections: Avoid plugin when shutdown is imminent

Eric Blake eblake at redhat.com
Fri Nov 17 03:26:53 UTC 2017


If nbdkit receives SIGINT while we are reading from the client,
it's better to avoid calling into the plugin for any work that
will further stall our response to the signal, and instead just
immediately give the client an ESHUTDOWN error.

Signed-off-by: Eric Blake <eblake at redhat.com>
---
 src/connections.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/connections.c b/src/connections.c
index 0ad252c..dada9aa 100644
--- a/src/connections.c
+++ b/src/connections.c
@@ -951,9 +951,14 @@ recv_request_send_reply (struct connection *conn)
   }

   /* Perform the request.  Only this part happens inside the request lock. */
-  plugin_lock_request (conn);
-  error = handle_request (conn, cmd, flags, offset, count, buf);
-  plugin_unlock_request (conn);
+  if (quit) {
+    error = ESHUTDOWN;
+  }
+  else {
+    plugin_lock_request (conn);
+    error = handle_request (conn, cmd, flags, offset, count, buf);
+    plugin_unlock_request (conn);
+  }

   /* Send the reply packet. */
  send_reply:
-- 
2.13.6




More information about the Libguestfs mailing list