bug in HTTCP.c

Hi,

sorry for being just a few hours too late for the last release, but think that I found a bug in HTTCP.c:

When requesting for an URL to a host that exists, but has not service running, the request is not finished in non-blocking mode. This causes the event loop not to return and requests hang.
Try fro example the url http://127.0.0.1:8797
When HTDoConnect() enters the state TCP_NEED_CONNECT, it starts connect(). On Win32, the results is always WSA_WOULDBLOCK because the TCP connection is not initiated immediatly. The event system simply calls that code portion again after receiving a FD_CONNECT event. Thus, the conenct() is called again and again, always returning WSA_WOULDBLOCK. It seems that the retry-counter of HTHost.c provides the right solution to stop connection retries after some time, however the counter seems not to be used and is not set up.
I fixed the problem by setting a default value for the retry counter in HTHost_new():

  if (pres) pres->retry = 3;

     return pres; 
 }

and changed the beginning of TCP_NEED_CONNECT part of HTDoConnect()  to

 case TCP_NEED_CONNECT:

  // for each connection attempt, decrease the retry value
  HTHost_decreaseRetry (host);

  if (!HTHost_retry(host)) {
   host->tcpstate = TCP_ERROR;
   break;
  }

#ifdef WWW_WIN_ASYNC
     HTHost_register(host, net, HTEvent_CONNECT);
#endif


I'm not sure how this is realted with non-blocking mode on Unix. I guess that the problem is the same when connect() returns EINPROGRESS.


Regards,

Jens

Received on Friday, 4 August 2000 11:00:27 UTC