aboutsummaryrefslogtreecommitdiff
path: root/blockdev-nbd.c
diff options
context:
space:
mode:
authorHani Benhabiles <kroosec@gmail.com>2014-05-13 00:35:15 +0100
committerMichael Tokarev <mjt@tls.msk.ru>2014-05-24 00:07:29 +0400
commit36af599417dde11747a27dc8550ff2281657a8ff (patch)
tree7bfe8799f5474489db6f25b2f6e77d3a72c0824c /blockdev-nbd.c
parentaef553fdcabbea8760cd4647ab14859095300023 (diff)
nbd: Close socket on negotiation failure.
Otherwise, the nbd client may hang waiting for the server response. Signed-off-by: Hani Benhabiles <hani@linux.com> Acked-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Diffstat (limited to 'blockdev-nbd.c')
-rw-r--r--blockdev-nbd.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index 922cf5657b..b60b66d66c 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -27,8 +27,8 @@ static void nbd_accept(void *opaque)
socklen_t addr_len = sizeof(addr);
int fd = accept(server_fd, (struct sockaddr *)&addr, &addr_len);
- if (fd >= 0) {
- nbd_client_new(NULL, fd, nbd_client_put);
+ if (fd >= 0 && !nbd_client_new(NULL, fd, nbd_client_put)) {
+ close(fd);
}
}