cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Patch to get ip address last requested

From: Jason Pump <jason_at_healthdash.com>
Date: Wed, 27 Jul 2005 19:04:58 -0700

Thanks, I will see what I can do. Because the connection object was null
at the time it got back I wasn't sure where to put the info.

Daniel Stenberg wrote:

> On Tue, 19 Jul 2005, Jason Pump wrote:
>
>> Here is the gist of a patch to get the ip address last requested in a
>> curl easy handle, *IF* you are using the curl multi handle and
>> calling curl_multi_perform(). If I get some time I will clean it up
>> if people think it's worthwhile. I definitely don't think this is the
>> ideal way to get the ip address, but I couldn't find anything else.
>> If there is a better way if someone can outline it I will see what I
>> can do. I might have posted this already, sorry if it's a dupe.
>
>
> I very much appreciate your effort!
>
> I would however much rather see this being implemented as yet another
> option to curl_easy_getinfo() instead. It could return a pointer to an
> allocated memory that you'd use curl_free() to clear up. Doesn't that
> make sense to you too? I'm always a bit hesitant to add brand new
> functions, especially for this kind of very limited use.
>
> I would also like to ask you to follow the curl coding style when you
> write code for inclusion: 2 space indents, opening braces on the same
> line as the if() and never more than one statement per line (i.e "if()
> return" needs to be in two lines).
>
>> If anyone if familiar with the various host caches I have a few
>> questions for you if you're up to it. Also if anyone want to outline
>> a different way to do this I will take a look.
>
>
> There is only one host cache, and you should address it with
> 'data->hostcache' where 'data' is a struct SessionHandle (which
> basically is an easy handle).
>
> Also note that your use of 'easy->state.first_host' will return the...
> eh, first host you requested data from, not the last one. If for
> example a HTTP redirect chain takes it to other hosts.
>
> I would instead suggest that you use the 'conn->ip_addr_str' pointer,
> or possibly you invent a new pointer within the UrlState struct that
> you set at the same time the conn->ip_addr_str gets set (since the
> conn version gets freed when the connection struct is freed, which I
> guess can happen before you use curl_easy_getinfo() to get the IP
> address) within the lib/connect.c:Curl_store_ip_addr() funciton.
>
Received on 2005-07-28