cURL / Mailing Lists / curl-library / Single Mail

curl-library

CURLOPT_OPENSOCKETFUNCTION behaviour

From: Yang Tse <yangsita_at_gmail.com>
Date: Thu, 16 Oct 2008 18:44:07 +0200

Hi folks,

While searching for strange structures, or 'funny' things we do with
some of them, in libcurl, I've come across something bit strange.

The issue is in the OPENSOCKETFUNCTION department.

Docs say, among other things, that this callback is allowed to modify
the address it initially receives.

http://curl.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTOPENSOCKETFUNCTION

And the code agrees with this. If the callback changes the address,
connection will be attempted/done against the 'new' address returned
from the callback.

The 'funny' part is that it does this quite silently inside function
singleipconnect() from connect.c, but functions which are calling this
are not 'notified' about this address-change.

If the address is changed, in current situation this leads to several
possibilities, libcurl survives and thinks that it is working against
the original intended address or somewhere along the way something
will stop working.

I have not done any tests relative to this, so I don't know if
allowing the address change to propagate all the way up the functions
calling singleipconnect() would actually work up to some point.

So before doing anything about it. Is current behaviour the desired
one, allowing to change the address of an already resolved host ?

Or should singleipconnect() be modified to not take in account a
potential address change done in the opensocket callback ?

-- 
-=[Yang]=-
Received on 2008-10-16