From 14645396e2c5bfec7615ebe2044e2ae5d0910709 Mon Sep 17 00:00:00 2001 From: mtortonesi Date: Thu, 18 Nov 2004 13:05:30 -0800 Subject: [PATCH] [svn] Fixed a timeout problem in src/retr.c:fd_read_body when using http_proxy. --- ChangeLog | 4 ---- src/ChangeLog | 12 ++++++++++++ src/connect.c | 4 ++-- src/retr.c | 7 +++++++ 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index a8ea9491..a95f837e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,3 @@ -2004-11-15 YAMAZAKI Makoto - - * src/netrc.c: Fix termination by assertion bug in netrc parsing. - 2004-05-09 David Fritz * windows/Makefile.src.bor: Fix broken build rule. Add clean target. diff --git a/src/ChangeLog b/src/ChangeLog index b260efa4..2fc91b81 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,15 @@ +2004-11-18 Mauro Tortonesi + + * connect.c: Minor correction to the comment in front of fd_peek. + +2004-11-18 Leonid Petrov + + * retr.c: Fix a timeout problem in fd_read_body when using http_proxy. + +2004-11-15 YAMAZAKI Makoto + + * netrc.c: Fix termination by assertion bug in netrc parsing. + 2004-05-09 David Fritz * mswindows.c (fake_fork): Pass entire command line to the child diff --git a/src/connect.c b/src/connect.c index ffa33cc0..4963512a 100644 --- a/src/connect.c +++ b/src/connect.c @@ -873,8 +873,8 @@ fd_read (int fd, char *buf, int bufsize, double timeout) return sock_read (fd, buf, bufsize); } -/* The same as xread, but don't actually read the data, just copy it - instead. */ +/* The same as fd_read, but don't actually read the data, just find out + what's the number of bytes available for reading. */ int fd_peek (int fd, char *buf, int bufsize, double timeout) diff --git a/src/retr.c b/src/retr.c index d9d03298..605db831 100644 --- a/src/retr.c +++ b/src/retr.c @@ -283,6 +283,13 @@ fd_read_body (int fd, FILE *out, long toread, long startpos, } ret = fd_read (fd, dlbuf, rdsize, tmout); + /* when retrieving from http-proxy wget sometimes does not trust the + * file length reported by server. + * this check is to tell wget not to stubbornly try to read again and + * again until another errno code was received. */ + if ( ret == -1 && errno == ETIMEDOUT && sum_read == toread && toread > 0 ) + break; + if (ret == 0 || (ret < 0 && errno != ETIMEDOUT)) break; /* read error */ else if (ret < 0) -- 2.39.2