Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Jan 2008 17:24:24 -0500
From:      "David Frascone" <dave@frascone.com>
To:        freebsd-current@freebsd.org
Subject:   Re: Small patch to fix top in large NIS environments
Message-ID:  <9cf5ced20801091424k60d136a7xc4a62d0e105fafff@mail.gmail.com>
In-Reply-To: <9cf5ced20801090915i3df2d4a1lc057a38b20fc5ac2@mail.gmail.com>
References:  <9cf5ced20801090915i3df2d4a1lc057a38b20fc5ac2@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
Oops -- should have checked -- I am not used to working as root, so root
didn't have my normal .cvsrc.  Unified diff attached.

-Dave

On Jan 9, 2008 12:15 PM, David Frascone <dave@frascone.com> wrote:

>
> 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
>

[-- Attachment #2 --]
Index: usr.bin/top/machine.c
===================================================================
RCS file: /usr/FreeBSD/cvsup/src/usr.bin/top/machine.c,v
retrieving revision 1.83
diff -u -r1.83 machine.c
--- usr.bin/top/machine.c	26 Oct 2007 08:00:40 -0000	1.83
+++ usr.bin/top/machine.c	9 Jan 2008 17:08:32 -0000
@@ -223,7 +223,7 @@
 static int swapmode(int *retavail, int *retfree);
 
 int
-machine_init(struct statics *statics)
+machine_init(struct statics *statics, char do_unames)
 {
 	int pagesize;
 	size_t modelen;
@@ -237,9 +237,11 @@
 	    modelen != sizeof(smpmode))
 		smpmode = 0;
 
-	while ((pw = getpwent()) != NULL) {
+	if (do_unames) {
+	    while ((pw = getpwent()) != NULL) {
 		if (strlen(pw->pw_name) > namelength)
 			namelength = strlen(pw->pw_name);
+	    }
 	}
 	if (smpmode && namelength > SMPUNAMELEN)
 		namelength = SMPUNAMELEN;
Index: contrib/top/top.c
===================================================================
RCS file: /usr/FreeBSD/cvsup/src/contrib/top/top.c,v
retrieving revision 1.23
diff -u -r1.23 top.c
--- contrib/top/top.c	4 May 2007 15:42:58 -0000	1.23
+++ contrib/top/top.c	9 Jan 2008 17:08:56 -0000
@@ -450,7 +450,7 @@
     }
 
     /* initialize the kernel memory interface */
-    if (machine_init(&statics) == -1)
+    if (machine_init(&statics, do_unames) == -1)
     {
 	exit(1);
     }

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9cf5ced20801091424k60d136a7xc4a62d0e105fafff>