Re: lwIP not using getaddrinfo()

2011-09-23 Thread Gisle Vanem

Gisle Vanem gva...@broadpark.no wrote:

It does. Trying that, I see lwIP uses getaddrinfo(), then calls gethostbyname() 
internally and then hangs forever waiting for some event:


...
kernel32.dll!WaitForSingleObjectEx+0xa8 


I see why. lwip_init() is called from easy.c. But the main input processing 
loop (polling the ifaces, checking timers, taking care of retransmissions etc.)
is supposed to be called from an interrupt context. That's the idea on embedded 
systems where that is safe to do.  This main-loop is missing in libcurl.


On Windows (no interrupt context) one needs to call lwIP's tcpip_init(). This 
should
create a threaded main-loop that gets everything going. Ref.
lwip-root/src/contrib/ports/win32/test.c

Yang are you there? What's your idea on this, since you added the lwIP stuff?
What's the motivation for calling lwip_init() only? AFAICS, this doesn't call 
the
required WinPcap init stuff. How can we best make libcurl+lwIP support
embedded and Win32 targets?

--gv



---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


lwIP not using getaddrinfo()

2011-09-22 Thread Gisle Vanem

Playing with lwIP, I see libcurl (Win32/MSVC) doesn't use getaddrinfo().
Although lwIP has it. This stack-trace shows it:

...
lwip.dll!sys_arch_sem_wait+0xbb
lwip.dll!netconn_gethostbyname+0xb6
lwip.dll!lwip_gethostbyname_r+0x87
curl.exe!Curl_ipv4_resolve_r+0x78
curl.exe!Curl_resolver_getaddrinfo+0x6b
curl.exe!Curl_resolv+0xf0
curl.exe!Curl_resolv_timeout+0x2c
curl.exe!resolve_server+0x12d
curl.exe!create_conn+0x4ea
curl.exe!Curl_connect+0x1d
curl.exe!connect_host+0x27
curl.exe!Curl_do_perform+0x42
curl.exe!Curl_perform+0x17
curl.exe!curl_easy_perform+0xa0
curl.exe!operate+0x244e
curl.exe!main+0x42
...

But I cannot make sense of the messy #ifdef-ing to select the correct
resolver. We have been told for like 10 years that gethostbyname() has 
been deprecated. At least on Windows. So someone help me fix this.


--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: lwIP not using getaddrinfo()

2011-09-22 Thread Daniel Stenberg

On Thu, 22 Sep 2011, Gisle Vanem wrote:

But I cannot make sense of the messy #ifdef-ing to select the correct 
resolver. We have been told for like 10 years that gethostbyname() has been 
deprecated. At least on Windows. So someone help me fix this.


It currently depends on ENABLE_IPV6, which in lib/setup.h (line 495) will 
define CURLRES_IPV6 then.


Does lwIP support IPv6? Otherwise I guess you can leave ENABLE_IPV6 undefined 
and just explicity define CURLRES_IPV6 and undefine CURLRES_IPV4,


--

 / daniel.haxx.se
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


Re: lwIP not using getaddrinfo()

2011-09-22 Thread Gisle Vanem

Daniel Stenberg dan...@haxx.se wrote:


On Thu, 22 Sep 2011, Gisle Vanem wrote:

But I cannot make sense of the messy #ifdef-ing to select the correct 
resolver. We have been told for like 10 years that gethostbyname() has been 
deprecated. At least on Windows. So someone help me fix this.


It currently depends on ENABLE_IPV6, which in lib/setup.h (line 495) will 
define CURLRES_IPV6 then.


Does lwIP support IPv6? Otherwise I guess you can leave ENABLE_IPV6 undefined 
and just explicity define CURLRES_IPV6 and undefine CURLRES_IPV4,


It does. Trying that, I see lwIP uses getaddrinfo(), then calls gethostbyname() 
internally and then hangs forever waiting for some event:


...
kernel32.dll!WaitForSingleObjectEx+0xa8 
kernel32.dll!WaitForSingleObject+0x12  
lwip.dll!sys_arch_sem_wait+0xbb

lwip.dll!netconn_gethostbyname+0xb6
lwip.dll!lwip_gethostbyname+0x11
libcurl.dll!Curl_getaddrinfo+0x43
libcurl.dll!Curl_resolv+0xd1
libcurl.dll!Curl_resolv_timeout+0x44
libcurl.dll!resolve_server+0x12d
libcurl.dll!create_conn+0x4ea
libcurl.dll!Curl_connect+0x1d
libcurl.dll!Curl_do_perform+0x5a
libcurl.dll!Curl_perform+0x17
libcurl.dll!curl_easy_perform+0xa0
curl.exe!operate+0x2468
...

Must check further.

--gv
---
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html