From a12a712a7dfbd2e2f4882ef2c90a9b2162166dd7 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 14 Mar 2017 12:11:56 +0100 Subject: nbd-client: fix handling of hungup connections After the switch to reading replies in a coroutine, nothing is reentering pending receive coroutines if the connection hangs. Move nbd_recv_coroutines_enter_all to the reply read coroutine, which is the place where hangups are detected. nbd_teardown_connection can simply wait for the reply read coroutine to detect the hangup and clean up after itself. This wouldn't be enough though because nbd_receive_reply returns 0 (rather than -EPIPE or similar) when reading from a hung connection. Fix the return value check in nbd_read_reply_entry. This fixes qemu-iotests 083. Reported-by: Max Reitz Signed-off-by: Paolo Bonzini Message-id: 20170314111157.14464-1-pbonzini@redhat.com Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- nbd/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nbd/client.c') diff --git a/nbd/client.c b/nbd/client.c index 3dc2564cd0..a58fb02cb4 100644 --- a/nbd/client.c +++ b/nbd/client.c @@ -812,6 +812,6 @@ ssize_t nbd_receive_reply(QIOChannel *ioc, NBDReply *reply) LOG("invalid magic (got 0x%" PRIx32 ")", magic); return -EINVAL; } - return 0; + return sizeof(buf); } -- cgit v1.2.1