Skip to main content
Sign in
Snippets Groups Projects
Commit d3fbccf2 authored by wangweidong's avatar wangweidong Committed by David S. Miller
Browse files

tipc: change lock_sock order in connect()


Instead of reaquiring the socket lock and taking the normal exit
path when a connection times out, we bail out early with a
return -ETIMEDOUT.

Reviewed-by: default avatarJon Maloy <jon.maloy@ericsson.com>
Reviewed-by: default avatarErik Hugne <erik.hugne@ericsson.com>
Signed-off-by: default avatarWang Weidong <wangweidong1@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 776a74ce
Branches
No related tags found
No related merge requests found
...@@ -1507,14 +1507,12 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen, ...@@ -1507,14 +1507,12 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
sock->state != SS_CONNECTING, sock->state != SS_CONNECTING,
timeout ? (long)msecs_to_jiffies(timeout) timeout ? (long)msecs_to_jiffies(timeout)
: MAX_SCHEDULE_TIMEOUT); : MAX_SCHEDULE_TIMEOUT);
lock_sock(sk);
if (res <= 0) { if (res <= 0) {
if (res == 0) if (res == 0)
res = -ETIMEDOUT; res = -ETIMEDOUT;
else return res;
; /* leave "res" unchanged */
goto exit;
} }
lock_sock(sk);
} }
if (unlikely(sock->state == SS_DISCONNECTING)) if (unlikely(sock->state == SS_DISCONNECTING))
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment