From: Mark Wooding Date: Sat, 3 Jan 2009 20:35:29 +0000 (+0000) Subject: pathmtu: Reset the timeout on each packet. X-Git-Tag: 1.0.0pre8~27 X-Git-Url: https://git.distorted.org.uk/~mdw/tripe/commitdiff_plain/664a5c0e4b3ad8849af41c78977708c85a66c02f pathmtu: Reset the timeout on each packet. 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. --- 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 ||