Small patch to fix top in large NIS environments

David Frascone dave at frascone.com
Wed Jan 9 09:43:28 PST 2008


The -u flag to top is supposed to limit uid lookups.  But, it was still
spinning through the entire password database with while (getpwent()).  At
Cisco, which has a fairly large NIS database, this takes forever, and top
never starts.

I filed this bug to address it:
http://www.freebsd.org/cgi/query-pr.cgi?pr=119490

The attached patch fixes it.  This is my first submission, so let me know if
this is the proper order, etc, to post the patches (i.e. file the bug, the
post a fix)

-Dave
-------------- next part --------------
Index: usr.bin/top/machine.c
===================================================================
RCS file: /usr/FreeBSD/cvsup/src/usr.bin/top/machine.c,v
retrieving revision 1.83
diff -r1.83 machine.c
226c226
< machine_init(struct statics *statics)
---
> machine_init(struct statics *statics, char do_unames)
240c240,241
< 	while ((pw = getpwent()) != NULL) {
---
> 	if (do_unames) {
> 	    while ((pw = getpwent()) != NULL) {
242a244
> 	    }
Index: contrib/top/top.c
===================================================================
RCS file: /usr/FreeBSD/cvsup/src/contrib/top/top.c,v
retrieving revision 1.23
diff -r1.23 top.c
453c453
<     if (machine_init(&statics) == -1)
---
>     if (machine_init(&statics, do_unames) == -1)


More information about the freebsd-current mailing list