cURL / Mailing Lists / curl-library / Single Mail

curl-library

problem fetching urls with IP address

From: Siddhartha Prakash Jain <spjain_at_in.firstrain.com>
Date: Wed, 1 Oct 2003 20:32:29 +0530

Hi,
        I am using curl-7.10.7 with ares. If I try to fetch http://http://208.184.138.70/ instead of http://www.rediff.com, I fail to connect to the server.
        Now I am using the "multi" interface provided by curl. And get error when we actually select on the set of sockets returned in curl_multi_fdset.

        I got things to work by making the following changes to the hostip.c file. I am new to curl so don't know if I am handling the problem correctly or not.
        I have made changes at two places:
        1. in my_getaddrinfo()
                if conn->async.done is true then I don't think we need to wait. This happens in case of an IP address being given. ares checks for "fake host" and calls the callback, after creating the right hostent struct.
        2. in Curl_resolv()
                we never get a non-NULL addr but if wait is FALSE then we can get the dns from conn->async.dns.

Here is the patch

Index: lib/hostip.c
===================================================================
RCS file: /curllib/lib/hostip.c,v
retrieving revision 1.1
diff -u -3 -r1.1 hostip.c
--- lib/hostip.c 30 Sep 2003 09:44:12 -0000 1.1
+++ lib/hostip.c 1 Oct 2003 15:00:28 -0000
@@ -316,14 +316,18 @@
     Curl_addrinfo *addr = my_getaddrinfo(conn, hostname, port, &wait);
     
     if (!addr) {
- if(wait)
+ if(wait){
         /* the response to our resolve call will come asynchronously at
- a later time, good or bad */
- rc = 1;
+ a later time, good or bad */
+ rc = 1;
+ }
+ else{
+ dns = conn->async.dns;
+ }
     }
     else
- /* we got a response, store it in the cache */
- dns = cache_resolv_response(data, addr, hostname, port);
+ /* we got a response, store it in the cache */
+ dns = cache_resolv_response(data, addr, hostname, port);
   }
 
   if(data->share)
@@ -553,7 +557,14 @@
       ares_gethostbyname(data->state.areschannel, hostname, PF_INET,
                          host_callback, conn);
 
- *waitp = TRUE; /* please wait for the response */
+
+ if(conn->async.done == TRUE){
+ *waitp = FALSE;
+ }
+ else{
+ *waitp = TRUE; /* please wait for the response */
+ }
+
     }
     else
       ares_destroy(data->state.areschannel);

Thanks in advance for you comments.

Siddhartha Jain.

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2003-10-01