summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHani Benhabiles <kroosec@gmail.com>2014-05-31 22:39:42 +0100
committerMichael Roth <mdroth@linux.vnet.ibm.com>2014-08-05 14:19:27 -0500
commit41971817a66d768e5ef8cb60891fcd77e05c924e (patch)
treeb701174c417bafaf6c07441b63f60ac7a14173ec
parent3f977a5be8f65fa13ca90189857fbce823338c2b (diff)
downloadqemu-41971817a66d768e5ef8cb60891fcd77e05c924e.tar.gz
nbd: Shutdown socket before closing.
This forces finishing data sending to client before closing the socket like in exports listing or replying with NBD_REP_ERR_UNSUP cases. Signed-off-by: Hani Benhabiles <kroosec@gmail.com> Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> (cherry picked from commit 27e5eae4577316f7e86a56eb7363d4e78f79e3e5) Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
-rw-r--r--blockdev-nbd.c1
-rw-r--r--qemu-nbd.c1
2 files changed, 2 insertions, 0 deletions
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index 18dc528761..b3a24740b2 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -28,6 +28,7 @@ static void nbd_accept(void *opaque)
int fd = accept(server_fd, (struct sockaddr *)&addr, &addr_len);
if (fd >= 0 && !nbd_client_new(NULL, fd, nbd_client_put)) {
+ shutdown(fd, 2);
close(fd);
}
}
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 4f53b9b079..8a49798b8a 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -372,6 +372,7 @@ static void nbd_accept(void *opaque)
if (nbd_client_new(exp, fd, nbd_client_closed)) {
nb_fds++;
} else {
+ shutdown(fd, 2);
close(fd);
}
}