Skip to content

Commit

Permalink
SUNRPC: Don't leak sockets in xs_local_connect()
Browse files Browse the repository at this point in the history
If there is still a closed socket associated with the transport, then we
need to trigger an autoclose before we can set up a new connection.

Reported-by: wanghai (M) <wanghai38@huawei.com>
Fixes: f004320 ("SUNRPC: Ensure we flush any closed sockets before xs_xprt_free()")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
  • Loading branch information
Trond Myklebust committed Apr 28, 2022
1 parent 00c94eb commit aad41a7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion net/sunrpc/xprtsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1950,6 +1950,9 @@ static void xs_local_connect(struct rpc_xprt *xprt, struct rpc_task *task)
struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
int ret;

if (transport->file)
goto force_disconnect;

if (RPC_IS_ASYNC(task)) {
/*
* We want the AF_LOCAL connect to be resolved in the
Expand All @@ -1962,11 +1965,17 @@ static void xs_local_connect(struct rpc_xprt *xprt, struct rpc_task *task)
*/
task->tk_rpc_status = -ENOTCONN;
rpc_exit(task, -ENOTCONN);
return;
goto out_wake;
}
ret = xs_local_setup_socket(transport);
if (ret && !RPC_IS_SOFTCONN(task))
msleep_interruptible(15000);
return;
force_disconnect:
xprt_force_disconnect(xprt);
out_wake:
xprt_clear_connecting(xprt);
xprt_wake_pending_tasks(xprt, -ENOTCONN);
}

#if IS_ENABLED(CONFIG_SUNRPC_SWAP)
Expand Down

0 comments on commit aad41a7

Please sign in to comment.