[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-wget] need some advice for 0 timeout code
From: |
Tim Ruehsen |
Subject: |
[Bug-wget] need some advice for 0 timeout code |
Date: |
Mon, 14 May 2012 16:07:51 +0200 |
User-agent: |
KMail/1.13.7 (Linux/3.2.0-2-amd64; KDE/4.7.4; x86_64; ; ) |
Hi,
using gnutls with --timeout=0 fails. When trying to repair it, I stumbled over
some code design flaws that I would like to fix.
[On 28.3.2012 we already had a short conversation to clarify that --timeout=0
means "no timeout" = "INFINITE timeout".]
--timeout=0 sets timeout values like opt.read_timeout to 0, which in turn
needs special care, since select_fd() takes a value of 0 as 'immediate return
/ polling' and has no special value for "INFINITY".
There are three obvious ways to fix the issue once and for all:
a)
when given the timeout value 0, use INFINITY and special handle this value in
select_fd() to call select with timeout NULL.
- INFINITY is defined in math.h which needs to be included in connect.c and
init.c.
- cmd_time() maybe needs a clone to set a 0 value to INFINITY.
- checks like if (timeout) have to be changed into if (timeout!=INFINITY).
b)
when given the timeout value 0, use a very high timeout value like 100 years
(maybe larger to handle future extrasolar communication ;-).
- since the code for timeout!=0 is very well tested since it is the normal
case, we won't *need* any further changes.
- we could optionally get rid of the if (timeout) ... extra code in connect.c
and gnutls (but get some extra calls to select()).
c) just fix gnutls.c.
- similar to a), but limited to gnutls.c and connect.c.
- gnutls seem to need NONBLOCKING sockets, so we would call select() /
select_fd() anyways. Again unneccessary extra code to maintain...
I tend to like b) the most because it's elegent and improves maintainability.
Which solution would you prefer resp. which solution has a chance being
accepted by the maintainer(s) ?
Tim
- [Bug-wget] need some advice for 0 timeout code,
Tim Ruehsen <=