Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Oct 1995 22:54:04 +0100
From:      Olof Johansson <offe@dawnrazor.campus.luth.se>
To:        "Justin T. Gibbs" <gibbs@freefall.FreeBSD.org>
Cc:        hackers@freebsd.org
Subject:   Re: wtmp efficiency 
Message-ID:  <199510162154.WAA08655@dawnrazor.campus.luth.se>
In-Reply-To: Your message of "Mon, 16 Oct 1995 14:14:34 MST." <199510162114.OAA19312@aslan.cdrom.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
I've found (and fixed) the problem.

It's the fact that ftp and uucp connections get 'ftp' or 'uucp' + pid as 
tty_line in wtmp. The pid isn't removed when looking up the tty, so the list 
gets bigger and bigger.
For 'ftp-only' wtmp files the time for parsing the file is proportional to 
n^2, where n is the number of entries in the file...
(I have an exam on data structures and algorithms next week *grin*).

The following patch fixes the problem.


*** last.c	Mon Aug  7 19:08:00 1995
--- lastold.c	Mon Oct 16 22:43:48 1995
***************
*** 202,207 ****
--- 202,215 ----
  				continue;
  			}
  			/*
+ 			 * Fix tty-line for ftp and uucp entries.
+ 			 * (same as in want(), see there for more info)
+ 			 */
+ 			if (!strncmp(bp->ut_line, "ftp", 3))
+ 				bp->ut_line[3] = '\0';
+ 			else if (!strncmp(bp->ut_line, "uucp", 3))
+ 				bp->ut_line[4] = '\0';
+ 			/*
  			 * if the line is '{' or '|', date got set; see
  			 * utmp(5) for more info.
  			 */




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