DNS weight logic wrong

Trying to understand the logic of the DNS cache, I found several things 
that look wrong.  First, the comparison logic in HTGetHostByName makes
it obvious that "small number" is "good".  (The comment

            double best_weight = 1e30;                        /* Pretty good */

is misleading.)  But HTDoConnect passes a negative value to 
HTDNS_updateWeigths as deltatime after a successful connect.
Fix: replace the two occurrences in HTTCP.c of

      me->connecttime -= HTGetTimeInMillis();

with

      me->connecttime = HTGetTimeInMillis() - me->connecttime;

Second, the values in HTTCP.c's #defines for TCP_PENALTY and TCP_DELAY
seem to be meant as seconds, but are added to me->connecttime
directly - there's a facor of 1000 missing somewhere.

Questions: HTDoConnect has

                    if (HT_HOSTUNREACHABLE(socerrno))
                        me->connecttime += TCP_DELAY;
                    else
                        me->connecttime += TCP_PENALTY;

Shouldn't that be the other way?
What are the other errors, anticipated to not be covered by
HT_HOSTUNREACHABLE? The comment for TCP_DELAY says:

/* x seconds penalty on a multi-homed host if IP-address is timed out */

Is the code using TCP_DELAY actually reached if a conect timeout occurs?


Nit: the spelling of "Weight" in HTDNS_updateWeigths (and some trace
messages in that function) is wrong.  I only noticed when searching
for "weight" didn't find anything. :)

   Klaus

Received on Wednesday, 3 February 1999 11:44:21 UTC