Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Oct 2001 23:22:01 -0500
From:      "Mishler, Barry A POJ" <Barry.A.Mishler@poj02.usace.army.mil>
To:        freebsd-net@FreeBSD.ORG
Subject:   Timeout on dns resolver functions
Message-ID:  <06F2D681CAF4774DBDD5852190A0CC213EF968@POJMAIL02.poj.usace.army.mil>

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

[-- Attachment #1 --]
I'm sure this has been discussed before but I've been unable to find a
proper solution...

Is there a nice portable way to establish a timeout on the resolver
routines?

I let trafshow run for several hours when it caused a flood of 'File Table
Full' syslog messages.  It turns out that the trafshow code sets an alarm()
before it calls gethostbyaddr and then it wraps the whole thing inside a
setjmp block.  When the reverse lookup takes too long, the gethostbyaddr is
terminated ungracefully leaving a file descriptor open.  After a while, this
file descriptor leakage fills up the table.

I've found that trafshow's addrtoname.c was lifted pretty much straight out
of the tcpdump collection.  The biggest difference is that tcpdump waits 20
seconds whereas trafshow defaults to a 2-second wait in order to keep things
moving.  So I can only assume that tcpdump would similarly fill up the FD
table if given the chance.

I don't know if this is relevant, but trafshow never leaked descriptors
until I upgraded from some version of 4.0-STABLE to 4.1-RELEASE.  I
confirmed this on two machines.  I never got around to tracking it down
until recently.  Sorry.

So what's a portable program to do?  How can this FD leakage be avoided?

Thanks in advance,
Barry

--
Barry Mishler
System/Network Manager
Japan Engineer District
U.S. Army Corps of Engineers

[-- Attachment #2 --]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>Timeout on dns resolver functions</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>I'm sure this has been discussed before but I've been unable to find a proper solution...</FONT>
</P>

<P><FONT SIZE=2>Is there a nice portable way to establish a timeout on the resolver routines?</FONT>
</P>

<P><FONT SIZE=2>I let trafshow run for several hours when it caused a flood of 'File Table Full' syslog messages.&nbsp; It turns out that the trafshow code sets an alarm() before it calls gethostbyaddr and then it wraps the whole thing inside a setjmp block.&nbsp; When the reverse lookup takes too long, the gethostbyaddr is terminated ungracefully leaving a file descriptor open.&nbsp; After a while, this file descriptor leakage fills up the table.</FONT></P>

<P><FONT SIZE=2>I've found that trafshow's addrtoname.c was lifted pretty much straight out of the tcpdump collection.&nbsp; The biggest difference is that tcpdump waits 20 seconds whereas trafshow defaults to a 2-second wait in order to keep things moving.&nbsp; So I can only assume that tcpdump would similarly fill up the FD table if given the chance.</FONT></P>

<P><FONT SIZE=2>I don't know if this is relevant, but trafshow never leaked descriptors until I upgraded from some version of 4.0-STABLE to 4.1-RELEASE.&nbsp; I confirmed this on two machines.&nbsp; I never got around to tracking it down until recently.&nbsp; Sorry.</FONT></P>

<P><FONT SIZE=2>So what's a portable program to do?&nbsp; How can this FD leakage be avoided?</FONT>
</P>

<P><FONT SIZE=2>Thanks in advance,</FONT>
<BR><FONT SIZE=2>Barry</FONT>
</P>

<P><FONT SIZE=2>--</FONT>
<BR><FONT SIZE=2>Barry Mishler</FONT>
<BR><FONT SIZE=2>System/Network Manager</FONT>
<BR><FONT SIZE=2>Japan Engineer District</FONT>
<BR><FONT SIZE=2>U.S. Army Corps of Engineers</FONT>
</P>

</BODY>
</HTML>

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