Commit f1d0c5ab authored by Ben Walker's avatar Ben Walker Committed by Tomasz Zawadzki
Browse files

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: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/475310


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 88808c5a
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -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;