Skip to content

Commit

Permalink
tipc: change lock_sock order in connect()
Browse files Browse the repository at this point in the history
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: Jon Maloy <[email protected]>
Reviewed-by: Erik Hugne <[email protected]>
Signed-off-by: Wang Weidong <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
wangweidong authored and davem330 committed Dec 16, 2013
1 parent 776a74c commit d3fbccf
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions net/tipc/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1507,14 +1507,12 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
sock->state != SS_CONNECTING,
timeout ? (long)msecs_to_jiffies(timeout)
: MAX_SCHEDULE_TIMEOUT);
lock_sock(sk);
if (res <= 0) {
if (res == 0)
res = -ETIMEDOUT;
else
; /* leave "res" unchanged */
goto exit;
return res;
}
lock_sock(sk);
}

if (unlikely(sock->state == SS_DISCONNECTING))
Expand Down

0 comments on commit d3fbccf

Please sign in to comment.