aboutsummaryrefslogtreecommitdiff
path: root/blockdev-nbd.c
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2016-01-14 16:41:01 +0800
committerPaolo Bonzini <pbonzini@redhat.com>2016-01-15 18:58:01 +0100
commitee7d7aabdaea4484e069cb99c9fc54e8cb24b56f (patch)
treeda85bcfd0c1092c266629d6afd9d75d59c98eea0 /blockdev-nbd.c
parente1dc68155cafabfd6a065391f7826d5d0992b46e (diff)
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>
Diffstat (limited to 'blockdev-nbd.c')
-rw-r--r--blockdev-nbd.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index bcdd18b3f6..4a758ac314 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -27,9 +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)) {
- shutdown(fd, 2);
- close(fd);
+ if (fd >= 0) {
+ nbd_client_new(NULL, fd, nbd_client_put);
}
}