| Summary: | fetch -T n is not timeout correctly when target server is down | ||
|---|---|---|---|
| Product: | Base System | Reporter: | Masachika ISHIZUKA <ishizuka> |
| Component: | bin | Assignee: | Dag-Erling Smørgrav <des> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | 4.1-RELEASE | ||
| Hardware: | Any | ||
| OS: | Any | ||
|
Description
Masachika ISHIZUKA
2000-08-15 12:50:00 UTC
On Tue, 15 Aug 2000 ishizuka@ish.org wrote: > >Description: > > % fetch -T 5 http://www.hoge.com/index.html > > When server 'www.hoge.com' is down or can't lookup address from > DNS server, fetch command is not timeout with 5 seconds. > Older version of fetch (with 4.0R or 3.4R) is timeout with 5 seconds. This reminded me of an old problem with ping(8). ^C doesn't work for killing ping when DNS lookup hangs, provided you wait a second or two for execution to reach res_send(). This is because res_send() retries after EINTR, so it doesn't work with signal handlers that just set a flag. ping's SIGINT handler was fixed a few years ago to just set a flag (previously it called stdio functions). The problem in fetch(1) seems to be the same. fetch's SIGINT and SIGALRM handlers just set a flag, so neither -T nor ^C can be used to kill fetch when DNS lookup hangs. ping's SIGALRM handler also just sets a flag, but this works right because ping only uses alarms to control syscalls and EINTR works right for syscalls. Bruce Responsible Changed From-To: freebsd-bugs->des Over to the maintainer. On Tue, 15 Aug 2000 ishizuka@ish.org wrote: > >Description: > > % fetch -T 5 http://www.hoge.com/index.html > > When server 'www.hoge.com' is down or can't lookup address from > DNS server, fetch command is not timeout with 5 seconds. > Older version of fetch (with 4.0R or 3.4R) is timeout with 5 seconds. I cannot realize this problem with accessing http://www.hoge.com/index.html. However, I heared from you that fetching to the server where is actually not exist something like "fetch -T 1 http://10.1.1.1/aaa.txt" causes this problem. Is this patch fix your problem? Index: lib/libfetch/common.c diff -u lib/libfetch/common.c.orig lib/libfetch/common.c --- lib/libfetch/common.c.orig Tue Jul 18 07:01:26 2000 +++ lib/libfetch/common.c Thu Aug 17 02:36:42 2000 @@ -201,7 +201,12 @@ if ((sd = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) == -1) continue; - if (connect(sd, res->ai_addr, res->ai_addrlen) != -1) + if (fetchTimeout) + alarm(fetchTimeout); + err = connect(sd, res->ai_addr, res->ai_addrlen); + if (fetchTimeout) + alarm(0); + if (err != -1) break; close(sd); sd = -1; -- Hajimu UMEMOTO @ Internet Mutual Aid Society Yokohama, Japan ume@mahoroba.org ume@bisd.hitachi.co.jp ume@FreeBSD.org http://www.imasy.org/~ume/ >>>Description: >> >> % fetch -T 5 http://www.hoge.com/index.html >> >> When server 'www.hoge.com' is down or can't lookup address from >> DNS server, fetch command is not timeout with 5 seconds. >> Older version of fetch (with 4.0R or 3.4R) is timeout with 5 seconds. > > I cannot realize this problem with accessing > http://www.hoge.com/index.html. However, I heared from you that > fetching to the server where is actually not exist something like > "fetch -T 1 http://10.1.1.1/aaa.txt" causes this problem. > Is this patch fix your problem? > > Index: lib/libfetch/common.c > diff -u lib/libfetch/common.c.orig lib/libfetch/common.c > --- lib/libfetch/common.c.orig Tue Jul 18 07:01:26 2000 > +++ lib/libfetch/common.c Thu Aug 17 02:36:42 2000 > @@ -201,7 +201,12 @@ > if ((sd = socket(res->ai_family, res->ai_socktype, > res->ai_protocol)) == -1) > continue; > - if (connect(sd, res->ai_addr, res->ai_addrlen) != -1) > + if (fetchTimeout) > + alarm(fetchTimeout); > + err = connect(sd, res->ai_addr, res->ai_addrlen); > + if (fetchTimeout) > + alarm(0); > + if (err != -1) > break; > close(sd); > sd = -1; Hi, this is ishizuka. Thank you very much. This patch fixed my problem. And, sorry to say that I wrote 'www.hoge.com' to mean 'some.nonexist.domain.or.server' but this domain and this server really exists. -- ishizuka@ish.org I'm aware of the problem, but not quite sure how to handle it. The timeout should be enforced by libfetch, not by fetch(1), but I can't see any easy way of doing it. DES -- Dag-Erling Smorgrav - des@flood.ping.uio.no State Changed From-To: open->feedback Fixed in -CURRENT, awaiting MFC. State Changed From-To: feedback->closed Fixed, thanks. |