diff options
author | Allan Stephens <allan.stephens@windriver.com> | 2011-05-26 13:44:34 -0400 |
---|---|---|
committer | Paul Gortmaker <paul.gortmaker@windriver.com> | 2011-09-01 11:16:37 -0400 |
commit | a0f40f02ef0783688233caf737a17f1f56283e2b (patch) | |
tree | b27c98ef211ca9148a0bc8e4707e09660c2da197 /net/tipc | |
parent | ff60af8c16aa3b8ee51a0a6b4c4ea42342d1607d (diff) |
tipc: Prevent rounding issues when saving connect timeout option
Saves a socket's TIPC_CONN_TIMEOUT socket option value in its original
form (milliseconds), rather than jiffies. This ensures that the exact
value set using setsockopt() is always returned by getsockopt(), without
being subject to rounding issues introduced by a ms->jiffies->ms
conversion sequence.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/socket.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index adb2eff4a102..fc3c281c127d 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
@@ -49,7 +49,7 @@ struct tipc_sock { | |||
49 | struct sock sk; | 49 | struct sock sk; |
50 | struct tipc_port *p; | 50 | struct tipc_port *p; |
51 | struct tipc_portid peer_name; | 51 | struct tipc_portid peer_name; |
52 | long conn_timeout; | 52 | unsigned int conn_timeout; |
53 | }; | 53 | }; |
54 | 54 | ||
55 | #define tipc_sk(sk) ((struct tipc_sock *)(sk)) | 55 | #define tipc_sk(sk) ((struct tipc_sock *)(sk)) |
@@ -231,7 +231,7 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol, | |||
231 | sock_init_data(sock, sk); | 231 | sock_init_data(sock, sk); |
232 | sk->sk_backlog_rcv = backlog_rcv; | 232 | sk->sk_backlog_rcv = backlog_rcv; |
233 | tipc_sk(sk)->p = tp_ptr; | 233 | tipc_sk(sk)->p = tp_ptr; |
234 | tipc_sk(sk)->conn_timeout = msecs_to_jiffies(CONN_TIMEOUT_DEFAULT); | 234 | tipc_sk(sk)->conn_timeout = CONN_TIMEOUT_DEFAULT; |
235 | 235 | ||
236 | spin_unlock_bh(tp_ptr->lock); | 236 | spin_unlock_bh(tp_ptr->lock); |
237 | 237 | ||
@@ -1369,7 +1369,7 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen, | |||
1369 | struct msghdr m = {NULL,}; | 1369 | struct msghdr m = {NULL,}; |
1370 | struct sk_buff *buf; | 1370 | struct sk_buff *buf; |
1371 | struct tipc_msg *msg; | 1371 | struct tipc_msg *msg; |
1372 | long timeout; | 1372 | unsigned int timeout; |
1373 | int res; | 1373 | int res; |
1374 | 1374 | ||
1375 | lock_sock(sk); | 1375 | lock_sock(sk); |
@@ -1434,7 +1434,8 @@ static int connect(struct socket *sock, struct sockaddr *dest, int destlen, | |||
1434 | res = wait_event_interruptible_timeout(*sk_sleep(sk), | 1434 | res = wait_event_interruptible_timeout(*sk_sleep(sk), |
1435 | (!skb_queue_empty(&sk->sk_receive_queue) || | 1435 | (!skb_queue_empty(&sk->sk_receive_queue) || |
1436 | (sock->state != SS_CONNECTING)), | 1436 | (sock->state != SS_CONNECTING)), |
1437 | timeout ? timeout : MAX_SCHEDULE_TIMEOUT); | 1437 | timeout ? (long)msecs_to_jiffies(timeout) |
1438 | : MAX_SCHEDULE_TIMEOUT); | ||
1438 | lock_sock(sk); | 1439 | lock_sock(sk); |
1439 | 1440 | ||
1440 | if (res > 0) { | 1441 | if (res > 0) { |
@@ -1696,7 +1697,7 @@ static int setsockopt(struct socket *sock, | |||
1696 | res = tipc_set_portunreturnable(tport->ref, value); | 1697 | res = tipc_set_portunreturnable(tport->ref, value); |
1697 | break; | 1698 | break; |
1698 | case TIPC_CONN_TIMEOUT: | 1699 | case TIPC_CONN_TIMEOUT: |
1699 | tipc_sk(sk)->conn_timeout = msecs_to_jiffies(value); | 1700 | tipc_sk(sk)->conn_timeout = value; |
1700 | /* no need to set "res", since already 0 at this point */ | 1701 | /* no need to set "res", since already 0 at this point */ |
1701 | break; | 1702 | break; |
1702 | default: | 1703 | default: |
@@ -1752,7 +1753,7 @@ static int getsockopt(struct socket *sock, | |||
1752 | res = tipc_portunreturnable(tport->ref, &value); | 1753 | res = tipc_portunreturnable(tport->ref, &value); |
1753 | break; | 1754 | break; |
1754 | case TIPC_CONN_TIMEOUT: | 1755 | case TIPC_CONN_TIMEOUT: |
1755 | value = jiffies_to_msecs(tipc_sk(sk)->conn_timeout); | 1756 | value = tipc_sk(sk)->conn_timeout; |
1756 | /* no need to set "res", since already 0 at this point */ | 1757 | /* no need to set "res", since already 0 at this point */ |
1757 | break; | 1758 | break; |
1758 | case TIPC_NODE_RECVQ_DEPTH: | 1759 | case TIPC_NODE_RECVQ_DEPTH: |