This is the mail archive of the
libc-hacker@cygnus.com
mailing list for the glibc project.
rpc.nfsd hanging
- To: libc-hacker@gnu.org
- Subject: rpc.nfsd hanging
- From: smurf@noris.de (Matthias Urlichs)
- Date: 19 Mar 1999 15:16:56 +0100
- Newsgroups: dist.glibc
- Organization: noris network GmbH, Nuernberg, FRG
- Xref: noris.net dist.glibc:8384
It's possible to hang DNS lookups indefinitely by the simple expedient of
installing a repeating SIGALRM handler which triggers faster than every
five seconds.
Because the poll() is unconditionally restarted on EINTR, as soon as the
first DNS server doesn't answer the first time you are in an empty loop. :-(
This happens for rpc.nfsd, with rather unfortunate consequences.
(The following patch should work, but it's untested.)
Index: base.325/resolv/res_send.c
--- base.325/resolv/res_send.c Tue, 15 Sep 1998 02:49:51 +0200 smurf (gnu_libc/m/b/3_res_send.c 1.1.1.4 666)
+++ test.10(w)/resolv/res_send.c Fri, 19 Mar 1999 14:48:54 +0100 smurf (gnu_libc/m/b/3_res_send.c 1.1.1.4 664)
@@ -511,6 +511,7 @@
* Use datagrams.
*/
int timeout;
+ time_t start_at;
struct pollfd pfd[1];
struct sockaddr_in from;
socklen_t fromlen;
@@ -615,6 +616,7 @@
timeout /= _res.nscount;
if (timeout <= 0)
timeout = 1000;
+ start_at = time(NULL);
wait:
if (s < 0 || s >= FD_SETSIZE) {
Perror(stderr, "s out-of-bounds", EMFILE);
@@ -625,8 +627,13 @@
pfd[0].events = POLLIN;
n = __poll(pfd, 1, timeout);
if (n < 0) {
- if (errno == EINTR)
+ if (errno == EINTR) {
+ timeout -= (time(NULL)-start_at)*1000;
+ if (timeout <= 0)
+ timeout = 0;
+ start_at = time(NULL);
goto wait;
+ }
Perror(stderr, "poll", errno);
res_close();
goto next_ns;
--
Matthias Urlichs | noris network GmbH | smurf@noris.de | ICQ: 20193661
The quote was selected randomly. Really. | http://www.noris.de/~smurf/
--
Junk your mind.
It is of no value to you in the game.
-- Carl Frederick
"est: Playing the Game the New Way"