sock: Simply spdk_sock_close

When this was originally implemented, it only accessed
*sock once or twice. As more stuff is added, it becomes
worthwhile to dereference the first level of **sock.

Change-Id: Ie31bb0210008f6341b071ba472aaedf897fa459a
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/475310
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Ben Walker 2019-11-20 13:27:01 -07:00 committed by Tomasz Zawadzki
parent 88808c5ab7
commit f1d0c5aba0

View File

@ -216,24 +216,25 @@ spdk_sock_accept(struct spdk_sock *sock)
}
int
spdk_sock_close(struct spdk_sock **sock)
spdk_sock_close(struct spdk_sock **_sock)
{
struct spdk_sock *sock = *_sock;
int rc;
if (*sock == NULL) {
if (sock == NULL) {
errno = EBADF;
return -1;
}
if ((*sock)->cb_fn != NULL) {
if (sock->cb_fn != NULL) {
/* This sock is still part of a sock_group. */
errno = EBUSY;
return -1;
}
rc = (*sock)->net_impl->close(*sock);
rc = sock->net_impl->close(sock);
if (rc == 0) {
*sock = NULL;
*_sock = NULL;
}
return rc;