aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/socket.c
diff options
context:
space:
mode:
authorwangweidong <wangweidong1@huawei.com>2013-12-11 20:36:42 -0500
committerDavid S. Miller <davem@davemloft.net>2013-12-16 12:48:35 -0500
commitd3fbccf2b01f8262faa1479712be6a55c626bdef (patch)
tree4f46ab8e4e49db33fcb9a95a7381c2aa4f37a8f2 /net/tipc/socket.c
parent776a74ce07a6e325fcfc04e272389947b1281159 (diff)
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: Jon Maloy <jon.maloy@ericsson.com> Reviewed-by: Erik Hugne <erik.hugne@ericsson.com> Signed-off-by: Wang Weidong <wangweidong1@huawei.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/socket.c')
-rw-r--r--net/tipc/socket.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 844bf349bb81..83f466e57fea 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -1507,14 +1507,12 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
1507 sock->state != SS_CONNECTING, 1507 sock->state != SS_CONNECTING,
1508 timeout ? (long)msecs_to_jiffies(timeout) 1508 timeout ? (long)msecs_to_jiffies(timeout)
1509 : MAX_SCHEDULE_TIMEOUT); 1509 : MAX_SCHEDULE_TIMEOUT);
1510 lock_sock(sk);
1511 if (res <= 0) { 1510 if (res <= 0) {
1512 if (res == 0) 1511 if (res == 0)
1513 res = -ETIMEDOUT; 1512 res = -ETIMEDOUT;
1514 else 1513 return res;
1515 ; /* leave "res" unchanged */
1516 goto exit;
1517 } 1514 }
1515 lock_sock(sk);
1518 } 1516 }
1519 1517
1520 if (unlikely(sock->state == SS_DISCONNECTING)) 1518 if (unlikely(sock->state == SS_DISCONNECTING))