All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] nbd/server: Suppress Broken pipe errors on abrupt disconnection
@ 2021-09-13 15:19 Richard W.M. Jones
  2021-09-14 14:40 ` Vladimir Sementsov-Ogievskiy
  2021-11-17 15:47 ` Eric Blake
  0 siblings, 2 replies; 13+ messages in thread
From: Richard W.M. Jones @ 2021-09-13 15:19 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, vsementsov, eblake, qemu-devel

$ rm -f /tmp/sock /tmp/pid
$ qemu-img create -f qcow2 /tmp/disk.qcow2 1M
$ qemu-nbd -t --format=qcow2 --socket=/tmp/sock --pid-file=/tmp/pid /tmp/disk.qcow2 &
$ nbdsh -u 'nbd+unix:///?socket=/tmp/sock' -c 'h.get_size()'
qemu-nbd: Disconnect client, due to: Failed to send reply: Unable to write to socket: Broken pipe
$ killall qemu-nbd

nbdsh is abruptly dropping the NBD connection here which is a valid
way to close the connection.  It seems unnecessary to print an error
in this case so this commit suppresses it.

Note that if you call the nbdsh h.shutdown() method then the message
was not printed:

$ nbdsh -u 'nbd+unix:///?socket=/tmp/sock' -c 'h.get_size()' -c 'h.shutdown()'

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
---
 nbd/server.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/nbd/server.c b/nbd/server.c
index 3927f7789d..e0a43802b2 100644
--- a/nbd/server.c
+++ b/nbd/server.c
@@ -2669,7 +2669,12 @@ static coroutine_fn void nbd_trip(void *opaque)
         ret = nbd_handle_request(client, &request, req->data, &local_err);
     }
     if (ret < 0) {
-        error_prepend(&local_err, "Failed to send reply: ");
+        if (errno != EPIPE) {
+            error_prepend(&local_err, "Failed to send reply: ");
+        } else {
+            error_free(local_err);
+            local_err = NULL;
+        }
         goto disconnect;
     }
 
-- 
2.32.0



^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-11-17 15:48 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-13 15:19 [PATCH v2] nbd/server: Suppress Broken pipe errors on abrupt disconnection Richard W.M. Jones
2021-09-14 14:40 ` Vladimir Sementsov-Ogievskiy
2021-09-14 14:52   ` Richard W.M. Jones
2021-09-14 15:21     ` Vladimir Sementsov-Ogievskiy
2021-09-14 16:32       ` Richard W.M. Jones
2021-09-15  7:15         ` Vladimir Sementsov-Ogievskiy
2021-09-15  9:00           ` Richard W.M. Jones
2021-09-15  9:11             ` Vladimir Sementsov-Ogievskiy
2021-09-17 16:10               ` Eric Blake
2021-09-17 16:05             ` Eric Blake
2021-09-14 19:06     ` Eric Blake
2021-09-14 19:01   ` Eric Blake
2021-11-17 15:47 ` Eric Blake

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.