diff options
author | ssouhlal <ssouhlal@FreeBSD.org> | 2005-09-02 14:58:26 +0000 |
---|---|---|
committer | ssouhlal <ssouhlal@FreeBSD.org> | 2005-09-02 14:58:26 +0000 |
commit | 912d183e0b4eff2d1cfeacc98dc5720f1461a947 (patch) | |
tree | 16657cede904f7cb178891ec87f984e54f79147c /usr.bin/ruptime | |
parent | 2f2c6e36696102642cd5fb1e5c4aa72de7bfdf8d (diff) | |
download | FreeBSD-src-912d183e0b4eff2d1cfeacc98dc5720f1461a947.zip FreeBSD-src-912d183e0b4eff2d1cfeacc98dc5720f1461a947.tar.gz |
- Do not allocate memory to entries in /var/rwho which have been down for
more than 4 days - waste of memory.
Obtained from: DragonFlyBSD (liamfoy)
MFC after: 3 days
Diffstat (limited to 'usr.bin/ruptime')
-rw-r--r-- | usr.bin/ruptime/ruptime.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/ruptime/ruptime.c b/usr.bin/ruptime/ruptime.c index 045a125..f0778ea 100644 --- a/usr.bin/ruptime/ruptime.c +++ b/usr.bin/ruptime/ruptime.c @@ -63,7 +63,7 @@ struct hs { int hs_nusers; } *hs; struct whod awhod; -#define LEFTEARTH(h) (now - (h)->hs_wd->wd_recvtime > 4*24*60*60) +#define LEFTEARTH(h) (now - (h) > 4*24*60*60) #define ISDOWN(h) (now - (h)->hs_wd->wd_recvtime > 11 * 60) #define WHDRSIZE (sizeof (awhod) - sizeof (awhod.wd_we)) @@ -208,6 +208,8 @@ ruptime(const char *host, int aflg, int (*cmp)(const void *, const void *)) if (cc < WHDRSIZE) continue; + if (LEFTEARTH(((struct whod *)buf)->wd_recvtime)) + continue; if (nhosts == hspace) { if ((hs = realloc(hs, (hspace += 40) * sizeof(*hs))) == NULL) @@ -241,8 +243,6 @@ ruptime(const char *host, int aflg, int (*cmp)(const void *, const void *)) qsort(hs, nhosts, sizeof(hs[0]), cmp); for (i = 0; i < (int)nhosts; i++) { hsp = &hs[i]; - if (LEFTEARTH(hsp)) - continue; if (ISDOWN(hsp)) { (void)printf("%-12.12s%s\n", hsp->hs_wd->wd_hostname, interval(now - hsp->hs_wd->wd_recvtime, "down")); |