From 664a5c0e4b3ad8849af41c78977708c85a66c02f Mon Sep 17 00:00:00 2001 Message-Id: <664a5c0e4b3ad8849af41c78977708c85a66c02f.1715496630.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sat, 3 Jan 2009 20:35:29 +0000 Subject: [PATCH] pathmtu: Reset the timeout on each packet. Organization: Straylight/Edgeware From: Mark Wooding Linux actually has the correct behaviour and updates the timeout argument to reflect the time remaining. Unfortunately we don't actually want to do that. So reset it each time. --- pathmtu/pathmtu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pathmtu/pathmtu.c b/pathmtu/pathmtu.c index acc88378..c86397fd 100644 --- a/pathmtu/pathmtu.c +++ b/pathmtu/pathmtu.c @@ -90,9 +90,9 @@ static int pathmtu(struct sockaddr_in *sin, double to) int mtu; int i; size_t sz; - struct timeval tv; + struct timeval tv, tvproto; - tv.tv_sec = to; tv.tv_usec = (to - tv.tv_sec) * 1000000; + tvproto.tv_sec = to; tvproto.tv_usec = (to - tvproto.tv_sec) * 1000000; if ((sk = socket(PF_INET, SOCK_DGRAM, 0)) < 0) goto fail_0; i = IP_PMTUDISC_DO; if (setsockopt(sk, SOL_IP, IP_MTU_DISCOVER, &i, sizeof(i))) @@ -102,7 +102,7 @@ static int pathmtu(struct sockaddr_in *sin, double to) sz = sizeof(mtu); if (getsockopt(sk, SOL_IP, IP_MTU, &mtu, &sz)) goto fail_1; if (write(sk, buf, mtu - 28) < 0) goto fail_1; - FD_SET(sk, &fd_in); + FD_SET(sk, &fd_in); tv = tvproto; if (select(sk + 1, &fd_in, 0, 0, &tv) < 0) goto fail_1; if (!FD_ISSET(sk, &fd_in)) break; if (read(sk, &i, 1) >= 0 || -- [mdw]