Browse Source

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>
Hani Benhabiles 11 years ago
parent
commit
27e5eae457
2 changed files with 2 additions and 0 deletions
  1. 1 0
      blockdev-nbd.c
  2. 1 0
      qemu-nbd.c

+ 1 - 0
blockdev-nbd.c

@@ -28,6 +28,7 @@ static void nbd_accept(void *opaque)
 
 
     int fd = accept(server_fd, (struct sockaddr *)&addr, &addr_len);
     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)) {
+        shutdown(fd, 2);
         close(fd);
         close(fd);
     }
     }
 }
 }

+ 1 - 0
qemu-nbd.c

@@ -372,6 +372,7 @@ static void nbd_accept(void *opaque)
     if (nbd_client_new(exp, fd, nbd_client_closed)) {
     if (nbd_client_new(exp, fd, nbd_client_closed)) {
         nb_fds++;
         nb_fds++;
     } else {
     } else {
+        shutdown(fd, 2);
         close(fd);
         close(fd);
     }
     }
 }
 }