Skip to content

Commit

Permalink
TL/MLX5: fix client's socket closing (openucx#831)
Browse files Browse the repository at this point in the history
  • Loading branch information
samnordmann authored and nsarka committed Oct 24, 2023
1 parent d52086e commit 386228c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/components/tl/mlx5/tl_mlx5_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ UCC_CLASS_INIT_FUNC(ucc_tl_mlx5_context_t,
UCC_CLASS_CALL_SUPER_INIT(ucc_tl_context_t, &tl_mlx5_config->super,
params->context);
memcpy(&self->cfg, tl_mlx5_config, sizeof(*tl_mlx5_config));
self->sock = 0;
self->rcache = NULL;
self->shared_pd = NULL;
self->shared_ctx = NULL;
Expand Down Expand Up @@ -73,8 +74,11 @@ UCC_CLASS_CLEANUP_FUNC(ucc_tl_mlx5_context_t)
tl_debug(self->super.super.lib, "failed to free ib ctx and pd");
};

if (!self->sock) {
close(self->sock);
}

ucc_mpool_cleanup(&self->req_mp, 1);
close(self->sock);
}

UCC_CLASS_DEFINE(ucc_tl_mlx5_context_t, ucc_tl_context_t);
Expand Down
8 changes: 5 additions & 3 deletions src/components/tl/mlx5/tl_mlx5_pd.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ ucc_status_t ucc_tl_mlx5_socket_init(ucc_tl_mlx5_context_t *ctx,

static ucc_status_t client_recv_data(int *shared_cmd_fd,
uint32_t *shared_pd_handle,
const char *sock_path,
const char *sock_path, int *sock_p,
ucc_tl_mlx5_lib_t *lib)
{
struct sockaddr_storage sockaddr = {};
Expand Down Expand Up @@ -159,7 +159,8 @@ static ucc_status_t client_recv_data(int *shared_cmd_fd,
goto out;
}

return status;
*sock_p = sock;
return UCC_OK;

out:
if (close(sock) == -1) {
Expand Down Expand Up @@ -229,7 +230,8 @@ ucc_status_t ucc_tl_mlx5_share_ctx_pd(ucc_tl_mlx5_context_t *ctx,
ucc_status_t status;

if (!is_ctx_owner) {
status = client_recv_data(&ctx_fd, &pd_handle, sock_path, lib);
status =
client_recv_data(&ctx_fd, &pd_handle, sock_path, &ctx->sock, lib);
if (UCC_OK != status) {
tl_debug(lib, "failed to share ctx & pd from client side");
return status;
Expand Down

0 comments on commit 386228c

Please sign in to comment.