qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 3/3] nbd: Shutdown socket before closing.


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH 3/3] nbd: Shutdown socket before closing.
Date: Tue, 03 Jun 2014 13:33:41 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0

Il 31/05/2014 23:39, Hani Benhabiles ha scritto:
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 <address@hidden>
---
 blockdev-nbd.c | 1 +
 qemu-nbd.c     | 1 +
 2 files changed, 2 insertions(+)

diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index b60b66d..e609f66 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, SHUT_RDWR);
         close(fd);
     }
 }
diff --git a/qemu-nbd.c b/qemu-nbd.c
index ba60436..bf42861 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, SHUT_RDWR);
         close(fd);
     }
 }


IIUC, what this does is ensure that the other side gets a FIN before it gets a RST. Is this correct?

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]