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>
This commit is contained in:
parent
aef553fdca
commit
36af599417
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -369,8 +369,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
Block a user