Skip to contentSkip to conversation

Incorrect time conversion in TIPC

PATCH New Eric Sesterhenn 1 participant 1 message Dec 8, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Incorrect time conversion in TIPC

hi,

the timeouts in tipc/socket.c dont match if HZ is not 1000, this patch changes it to use the proper conversion functions.

net/tipc/socket.c renamed from net/tipc/socket.c.orig +3 -3
@@ -209,7 +209,7 @@ static int tipc_create(struct net *net, 
 
 	sock_init_data(sock, sk);
 	init_waitqueue_head(sk->sk_sleep);
-	sk->sk_rcvtimeo = 8 * HZ;   /* default connect timeout = 8s */
+	sk->sk_rcvtimeo = msecs_to_jiffies(8000);   /* default connect timeout = 8s */
 
 	tsock = tipc_sk(sk);
 	port = tipc_get_port(ref);
@@ -1535,7 +1535,7 @@ static int setsockopt(struct socket *soc
 		res = tipc_set_portunreturnable(tsock->p->ref, value);
 		break;
 	case TIPC_CONN_TIMEOUT:
-		sock->sk->sk_rcvtimeo = (value * HZ / 1000);
+		sock->sk->sk_rcvtimeo = msecs_to_jiffies(value);
 		break;
 	default:
 		res = -EINVAL;
@@ -1588,7 +1588,7 @@ static int getsockopt(struct socket *soc
 		res = tipc_portunreturnable(tsock->p->ref, &value);
 		break;
 	case TIPC_CONN_TIMEOUT:
-		value = (sock->sk->sk_rcvtimeo * 1000) / HZ;
+		value = jiffies_to_msecs(sock->sk->sk_rcvtimeo);
 		break;
 	default:
 		res = -EINVAL;