Commit 2f1cd867 authored by Ziye Yang's avatar Ziye Yang Committed by Tomasz Zawadzki
Browse files

sock/uring: Refactor the code in uring_sock_close



Use the same style compared the code in posix_sock_close.
Thus if we cannot close sock->fd, i.e., we leak the fd,
but we can still free the memory related with uring sock.

Signed-off-by: default avatarZiye Yang <ziye.yang@intel.com>
Change-Id: Id2f0e8a2c7065f100c2b009e76a49b528fd221b6
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6539


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
parent be57e2a6
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -585,19 +585,20 @@ static int
uring_sock_close(struct spdk_sock *_sock)
{
	struct spdk_uring_sock *sock = __uring_sock(_sock);
	int rc;

	assert(TAILQ_EMPTY(&_sock->pending_reqs));
	assert(sock->group == NULL);

	/* If the socket fails to close, the best choice is to
	 * leak the fd but continue to free the rest of the sock
	 * memory. */
	close(sock->fd);

	spdk_pipe_destroy(sock->recv_pipe);
	free(sock->recv_buf);
	rc = close(sock->fd);
	if (rc == 0) {
	free(sock);
	}

	return rc;
	return 0;
}

static ssize_t