Re: gethostbyname() timeout

> This problem is observed both on linux (SuSE 6.2 w./kernel 2.2.10) and 
> Win NT4.
> 
> We have a graphical editor program that uses libwww for HTTP support.
> Every time we try to load a file, we first look in a local cache (the
> application's own cache.  Not the one supplied by libwww), and if the
> file isn't there we try doing an HTTP get to its actual whereabouts.
> 
> So far, so good.
> 
> However, if the machine running the graphical editor is offline, and a 
> file cannot be found in the local cache, the editor freezes up for
> long periods of time.
> 
> The reason is that it is stuck in gethostbyname(), inside
> HTGetHostByName() in HTDNS.c.
> 
> I have cached missing host names outside of libwww, but the GUI freeze 
> caused by that first call to gethostbyname() is big enough that the
> BUG will probably still be counted as unfixed.
> 
> Maybe the timeout period of gethostbyname() can be reduced?  However
> searches on the net has shown me no such options, neither for winsock
> nor linux.
> 
> Maybe one approach to detecting the precense of a connected network
> would be to ping a fixed IP number?  However we may still be connected 
> to a network and reach some machines, with ping to a particular IP
> being blocked by routers or jammed by traffic.
> 
> Any and all ideas are apprciated!

I think the first information you need is the host name being researched. 
On Linux, the strace command will find it. Try something like this:
strace -f -F -o myprog.trace myprog

When the program terminates, view myprog.trace. Note that the host name 
(say www.ibm.com) will not appear as that string; the component parts are 
broken up dp it will look like this excerpt from running nslookup:

11107 socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 4
11107 sendto(4, "\357=\1\0\0\1\0\0\0\0\0\0\3www\3ibm\3com\0\0\1\0\1", 29, 
0, {sin_family=AF_INET
, sin_port=htons(53), sin_addr=inet_addr("192.168.1.6")}, 16) = 29
11107 select(5, [4], NULL, NULL, {5, 0}) = 1 (in [4], left {4, 950000})
11107 recvfrom(4, "\357=\201\200\0\1\0\2\0\6\0\5\3www\3ibm\3com\0\0\1\0\1".
.., 65536, 0, {sin_fa
mily=AF_INET, sin_port=htons(53), sin_addr=inet_addr("192.168.1.6")}, 
[16]) = 300
11107 close(4)                          = 0


Note: 
strace -f works on RHL 5 but not 6.
I think strace -F does not work on RHL 5; it does on RHL 6
strace -f -F works on both.


-- 
Cheers
John Summerfield
http://os2.ami.com.au/os2/ for OS/2 support.
Configuration, networking, combined IBM ftpsites index.

Received on Wednesday, 15 March 2000 10:03:52 UTC