When 'w' finds an IP address in the ut_host field, it attempts to do
a gethostbyname() on it. That can take a long time... (especially if the reason the IP address is in there in the first place is because login/rlogind/telnetd couldn't find it either....) This patch reduces the gethostbyaddr lookup time to 2 seconds, the idea being that if the local nameserver knows the answer, it'll answer within that time, otherwise we dont care... :-) This change doesn't do anything about whether or not w should do this in the first place, but at least it will make the current behavior less painful. Reviewed by: David Greenman
This commit is contained in:
parent
7908b94389
commit
6367cd09b8
@ -77,6 +77,9 @@ static char sccsid[] = "@(#)w.c 8.4 (Berkeley) 4/16/94";
|
||||
#include <utmp.h>
|
||||
#include <vis.h>
|
||||
|
||||
#include <arpa/nameser.h>
|
||||
#include <resolv.h>
|
||||
|
||||
#include "extern.h"
|
||||
|
||||
struct timeval boottime;
|
||||
@ -169,6 +172,11 @@ main(argc, argv)
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (!(_res.options & RES_INIT))
|
||||
res_init();
|
||||
_res.retrans = 2; /* resolver timeout to 2 seconds per try */
|
||||
_res.retry = 1; /* only try once.. */
|
||||
|
||||
if ((kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf)) == NULL)
|
||||
errx(1, "%s", errbuf);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user