]> xenbits.xensource.com Git - qemu-upstream-4.5-testing.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>
Tue, 5 Aug 2014 19:19:27 +0000 (14:19 -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 4f53b9b079f94c016eef7904ed6f0cf91ed17db6..8a49798b8a4a0a7e1fd78d7d6506216434e32540 100644 (file)
@@ -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);
     }
 }