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: Ziye Yang <ziye.yang@intel.com> Change-Id: Id2f0e8a2c7065f100c2b009e76a49b528fd221b6 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6539 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
parent
be57e2a6ec
commit
2f1cd867f3
@ -585,19 +585,20 @@ static int
|
|||||||
uring_sock_close(struct spdk_sock *_sock)
|
uring_sock_close(struct spdk_sock *_sock)
|
||||||
{
|
{
|
||||||
struct spdk_uring_sock *sock = __uring_sock(_sock);
|
struct spdk_uring_sock *sock = __uring_sock(_sock);
|
||||||
int rc;
|
|
||||||
|
|
||||||
assert(TAILQ_EMPTY(&_sock->pending_reqs));
|
assert(TAILQ_EMPTY(&_sock->pending_reqs));
|
||||||
assert(sock->group == NULL);
|
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);
|
spdk_pipe_destroy(sock->recv_pipe);
|
||||||
free(sock->recv_buf);
|
free(sock->recv_buf);
|
||||||
rc = close(sock->fd);
|
free(sock);
|
||||||
if (rc == 0) {
|
|
||||||
free(sock);
|
|
||||||
}
|
|
||||||
|
|
||||||
return rc;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t
|
||||||
|
Loading…
Reference in New Issue
Block a user