mirror of https://github.com/xemu-project/xemu.git
nbd: Close socket on negotiation failure.
Otherwise, the nbd client may hang waiting for the server response.
Signed-off-by: Hani Benhabiles <hani@linux.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(cherry picked from commit 36af599417
)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
This commit is contained in:
parent
cf392d2c7c
commit
25351f6a9a
|
@ -27,8 +27,8 @@ static void nbd_accept(void *opaque)
|
|||
socklen_t addr_len = sizeof(addr);
|
||||
|
||||
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)) {
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -299,8 +299,10 @@ static void nbd_accept(void *opaque)
|
|||
return;
|
||||
}
|
||||
|
||||
if (fd >= 0 && nbd_client_new(exp, fd, nbd_client_closed)) {
|
||||
if (nbd_client_new(exp, fd, nbd_client_closed)) {
|
||||
nb_fds++;
|
||||
} else {
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue