diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1999-08-01 06:38:21 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1999-08-01 06:38:21 +0000 |
commit | bb524b27a4d0e3e1ba42f2a66326faa5ac671f65 (patch) | |
tree | e0be39c149e9dbd1d089b28e04916d9ce495130c | |
parent | ac603ab1a99749c8148f24d993eb0259d12dee4b (diff) | |
download | fetchmail-bb524b27a4d0e3e1ba42f2a66326faa5ac671f65.tar.gz fetchmail-bb524b27a4d0e3e1ba42f2a66326faa5ac671f65.tar.bz2 fetchmail-bb524b27a4d0e3e1ba42f2a66326faa5ac671f65.zip |
Better MONITOR_SLOP fix.
svn path=/trunk/; revision=2528
-rw-r--r-- | interface.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/interface.c b/interface.c index d1295f51..a062f5dc 100644 --- a/interface.c +++ b/interface.c @@ -62,9 +62,10 @@ static char *netdevfmt; /* * Count of packets to see on an interface before monitor considers it up. * Needed because when pppd shuts down the link, the packet counts go up - * by two (one rx and one tx?, maybe). A value of 2 seems to do the trick. + * by two (one rx and one tx?, maybe). A value of 2 seems to do the trick, + * but we'll give it some extra. */ -#define MONITOR_SLOP 2 +#define MONITOR_SLOP 5 void interface_init(void) /* figure out which /proc/dev/net format to use */ @@ -468,13 +469,32 @@ int interface_approve(struct hostdata *hp) hp->monitor, hp->monitor_io); #endif /* if monitoring, check link for activity if it is up */ - if (get_ifinfo(hp->monitor, &ifinfo) && - hp->monitor_io - (ifinfo.rx_packets + - ifinfo.tx_packets) >= -MONITOR_SLOP) { + if (get_ifinfo(hp->monitor, &ifinfo)) + { + int diff = (ifinfo.rx_packets + ifinfo.tx_packets) + - hp->monitor_io; + + /* + * There are three cases here: + * + * (a) If the new packet count is less than the recorded one, + * probably pppd was restarted while fetchmail was running. + * Don't skip. + * + * (b) newpacket count is greater than the old packet count, + * but the difference is small and may just reflect the overhead + * of a link shutdown. Skip. + * + * (c) newpacket count is greater than the old packet count, + * and the difference is large. Connection is live. Don't skip. + */ + if (diff > 0 && diff <= MONITOR_SLOP) + { (void) report(stdout, _("skipping poll of %s, %s inactive\n"), hp->pollname, hp->monitor); return(FALSE); + } } #ifdef ACTIVITY_DEBUG |