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>
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);
}
}
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);
}
}