aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
authorAllan Stephens <allan.stephens@windriver.com>2010-08-17 07:00:15 -0400
committerDavid S. Miller <davem@davemloft.net>2010-08-17 20:31:59 -0400
commit564e83b51a12b794e3f63a2d872398e1ee21616f (patch)
tree6785882fa955a768c9859291d8b5a32826efe9a7 /net/tipc
parentc2de58140a380172610b6a0f07f975abb2fbb311 (diff)
tipc: Allow connect() to wait indefinitely
Cause a socket whose TIPC_CONN_TIMEOUT option is zero to wait indefinitely for a response to a connection request using connect(). Previously, specifying a timeout of 0 ms resulted in an immediate timeout, which was inconsistent with the behavior specified by Posix for a socket's receive and send timeout. Signed-off-by: Allan Stephens <allan.stephens@windriver.com> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc')
-rw-r--r--net/tipc/socket.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 7b81fdd4f6d6..f7ac94de24fe 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -64,6 +64,7 @@ struct tipc_sock {
64 struct sock sk; 64 struct sock sk;
65 struct tipc_port *p; 65 struct tipc_port *p;
66 struct tipc_portid peer_name; 66 struct tipc_portid peer_name;
67 long conn_timeout;
67}; 68};
68 69
69#define tipc_sk(sk) ((struct tipc_sock *)(sk)) 70#define tipc_sk(sk) ((struct tipc_sock *)(sk))
@@ -240,9 +241,9 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol,
240 sock->state = state; 241 sock->state = state;
241 242
242 sock_init_data(sock, sk); 243 sock_init_data(sock, sk);
243 sk->sk_rcvtimeo = msecs_to_jiffies(CONN_TIMEOUT_DEFAULT);
244 sk->sk_backlog_rcv = backlog_rcv; 244 sk->sk_backlog_rcv = backlog_rcv;
245 tipc_sk(sk)->p = tp_ptr; 245 tipc_sk(sk)->p = tp_ptr;
246 tipc_sk(sk)->conn_timeout = msecs_to_jiffies(CONN_TIMEOUT_DEFAULT);
246 247
247 spin_unlock_bh(tp_ptr->lock); 248 spin_unlock_bh(tp_ptr->lock);
248 249
@@ -1385,6 +1386,7 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
1385 struct msghdr m = {NULL,}; 1386 struct msghdr m = {NULL,};
1386 struct sk_buff *buf; 1387 struct sk_buff *buf;
1387 struct tipc_msg *msg; 1388 struct tipc_msg *msg;
1389 long timeout;
1388 int res; 1390 int res;
1389 1391
1390 lock_sock(sk); 1392 lock_sock(sk);
@@ -1445,11 +1447,12 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen,
1445 1447
1446 /* Wait until an 'ACK' or 'RST' arrives, or a timeout occurs */ 1448 /* Wait until an 'ACK' or 'RST' arrives, or a timeout occurs */
1447 1449
1450 timeout = tipc_sk(sk)->conn_timeout;
1448 release_sock(sk); 1451 release_sock(sk);
1449 res = wait_event_interruptible_timeout(*sk_sleep(sk), 1452 res = wait_event_interruptible_timeout(*sk_sleep(sk),
1450 (!skb_queue_empty(&sk->sk_receive_queue) || 1453 (!skb_queue_empty(&sk->sk_receive_queue) ||
1451 (sock->state != SS_CONNECTING)), 1454 (sock->state != SS_CONNECTING)),
1452 sk->sk_rcvtimeo); 1455 timeout ? timeout : MAX_SCHEDULE_TIMEOUT);
1453 lock_sock(sk); 1456 lock_sock(sk);
1454 1457
1455 if (res > 0) { 1458 if (res > 0) {
@@ -1712,7 +1715,7 @@ static int setsockopt(struct socket *sock,
1712 res = tipc_set_portunreturnable(tport->ref, value); 1715 res = tipc_set_portunreturnable(tport->ref, value);
1713 break; 1716 break;
1714 case TIPC_CONN_TIMEOUT: 1717 case TIPC_CONN_TIMEOUT:
1715 sk->sk_rcvtimeo = msecs_to_jiffies(value); 1718 tipc_sk(sk)->conn_timeout = msecs_to_jiffies(value);
1716 /* no need to set "res", since already 0 at this point */ 1719 /* no need to set "res", since already 0 at this point */
1717 break; 1720 break;
1718 default: 1721 default:
@@ -1767,7 +1770,7 @@ static int getsockopt(struct socket *sock,
1767 res = tipc_portunreturnable(tport->ref, &value); 1770 res = tipc_portunreturnable(tport->ref, &value);
1768 break; 1771 break;
1769 case TIPC_CONN_TIMEOUT: 1772 case TIPC_CONN_TIMEOUT:
1770 value = jiffies_to_msecs(sk->sk_rcvtimeo); 1773 value = jiffies_to_msecs(tipc_sk(sk)->conn_timeout);
1771 /* no need to set "res", since already 0 at this point */ 1774 /* no need to set "res", since already 0 at this point */
1772 break; 1775 break;
1773 case TIPC_NODE_RECVQ_DEPTH: 1776 case TIPC_NODE_RECVQ_DEPTH: