nbd: Always call "close_fn" in nbd_client_new

Rename the parameter "close" to "close_fn" to disambiguous with
close(2).

This unifies error handling paths of NBDClient allocation:
nbd_client_new will shutdown the socket and call the "close_fn" callback
if negotiation failed, so the caller don't need a different path than
the normal close.

The returned pointer is never used, make it void in preparation for the
next patch.

Signed-off-by: Fam Zheng <famz@redhat.com>
Message-Id: <1452760863-25350-2-git-send-email-famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Fam Zheng 2016-01-14 16:41:01 +08:00 committed by Paolo Bonzini
parent e1dc68155c
commit ee7d7aabda
4 changed files with 11 additions and 18 deletions

View file

@ -333,13 +333,9 @@ static void nbd_accept(void *opaque)
return;
}
if (nbd_client_new(exp, fd, nbd_client_closed)) {
nb_fds++;
nbd_update_server_fd_handler(server_fd);
} else {
shutdown(fd, 2);
close(fd);
}
nb_fds++;
nbd_update_server_fd_handler(server_fd);
nbd_client_new(exp, fd, nbd_client_closed);
}
static void nbd_update_server_fd_handler(int fd)