]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
nbd: Shutdown socket before closing.
authorHani Benhabiles <kroosec@gmail.com>
Sat, 31 May 2014 21:39:42 +0000 (22:39 +0100)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Wed, 16 Jul 2014 00:28:02 +0000 (19:28 -0500)
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>
blockdev-nbd.c
qemu-nbd.c

index 18dc528761adf89663e338b604caedba716bb6c4..b3a24740b2dbc8f66b84955a125f05ac102ff860 100644 (file)
@@ -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);
     }
 }
index 7a2cff92c2a6d4a7fb174ff9e738cf2f17b145fe..474966f4684a75b19f9b997797e102f9a8aae470 100644 (file)
@@ -302,6 +302,7 @@ static void nbd_accept(void *opaque)
     if (nbd_client_new(exp, fd, nbd_client_closed)) {
         nb_fds++;
     } else {
+        shutdown(fd, 2);
         close(fd);
     }
 }