diff options
author | Allan Stephens <allan.stephens@windriver.com> | 2008-04-14 00:35:11 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-04-14 00:35:11 -0400 |
commit | 3654ea02f2819cf8821c0acd35bc7cded5f1f2a9 (patch) | |
tree | d2bea8de80c3da3853160937560d30cfdfc23e02 | |
parent | 9673693284763417ea5edcdebc1a0c5d1dead51c (diff) |
[TIPC]: Improve socket time conversions
This patch modifies TIPC's socket code to use standard kernel
routines to handle time conversions between jiffies and ms.
This ensures proper operation even when HZ isn't 1000.
Acknowledgements to Eric Sesterhenn <snakebyte@gmx.de> for
identifying this issue and proposing a solution.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/tipc/socket.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index d3f9c2d87b0d..ca6f52f392a9 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
@@ -58,7 +58,8 @@ | |||
58 | #define SS_LISTENING -1 /* socket is listening */ | 58 | #define SS_LISTENING -1 /* socket is listening */ |
59 | #define SS_READY -2 /* socket is connectionless */ | 59 | #define SS_READY -2 /* socket is connectionless */ |
60 | 60 | ||
61 | #define OVERLOAD_LIMIT_BASE 5000 | 61 | #define OVERLOAD_LIMIT_BASE 5000 |
62 | #define CONN_TIMEOUT_DEFAULT 8000 /* default connect timeout = 8s */ | ||
62 | 63 | ||
63 | struct tipc_sock { | 64 | struct tipc_sock { |
64 | struct sock sk; | 65 | struct sock sk; |
@@ -170,7 +171,7 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol) | |||
170 | } | 171 | } |
171 | 172 | ||
172 | sock_init_data(sock, sk); | 173 | sock_init_data(sock, sk); |
173 | sk->sk_rcvtimeo = 8 * HZ; /* default connect timeout = 8s */ | 174 | sk->sk_rcvtimeo = msecs_to_jiffies(CONN_TIMEOUT_DEFAULT); |
174 | 175 | ||
175 | tsock = tipc_sk(sk); | 176 | tsock = tipc_sk(sk); |
176 | port = tipc_get_port(ref); | 177 | port = tipc_get_port(ref); |
@@ -1529,7 +1530,7 @@ static int setsockopt(struct socket *sock, | |||
1529 | res = tipc_set_portunreturnable(tsock->p->ref, value); | 1530 | res = tipc_set_portunreturnable(tsock->p->ref, value); |
1530 | break; | 1531 | break; |
1531 | case TIPC_CONN_TIMEOUT: | 1532 | case TIPC_CONN_TIMEOUT: |
1532 | sock->sk->sk_rcvtimeo = (value * HZ / 1000); | 1533 | sock->sk->sk_rcvtimeo = msecs_to_jiffies(value); |
1533 | break; | 1534 | break; |
1534 | default: | 1535 | default: |
1535 | res = -EINVAL; | 1536 | res = -EINVAL; |
@@ -1582,7 +1583,7 @@ static int getsockopt(struct socket *sock, | |||
1582 | res = tipc_portunreturnable(tsock->p->ref, &value); | 1583 | res = tipc_portunreturnable(tsock->p->ref, &value); |
1583 | break; | 1584 | break; |
1584 | case TIPC_CONN_TIMEOUT: | 1585 | case TIPC_CONN_TIMEOUT: |
1585 | value = (sock->sk->sk_rcvtimeo * 1000) / HZ; | 1586 | value = jiffies_to_msecs(sock->sk->sk_rcvtimeo); |
1586 | break; | 1587 | break; |
1587 | default: | 1588 | default: |
1588 | res = -EINVAL; | 1589 | res = -EINVAL; |