cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Using libcurl on top of lwip on POSIX embedded platform (take 2)

From: Mason <mpeg.blue_at_free.fr>
Date: Tue, 20 Mar 2012 17:16:42 +0100

Daniel Stenberg wrote:

> Mason wrote:
>
>> Technically, one should not call lwip_init, as lwip_init is called from
>> tcpip_init. Philosophically, why would library code initialize the network
>> stack on which the library code depends?
>
> Philosophically, we do it for win32 if the correct bit is set
> (CURL_GLOBAL_WIN32) because it might be that the application doesn't use
> anything else network-related than libcurl and then it might make sense. Do
> you think it would make sense to add another such bit, like CURL_GLOBAL_LWIP
> to cater for the user to decide which way to do it?

It's a complex issue...

Guenter's description is pretty accurate. When using lwip as the
system's one and only stack (as I am), lwip is initialized a few
milliseconds after boot, and it makes no sense to consider
initializing it in library code.

>> On my platform, at boot-time, the network stack is one of the first things
>> initialized, long before any thread has had a chance to run libcurl code.
>> Perhaps this is a Windows peculiarity?
>
> How can it be Windows specific? Isn't it rather about how a system or
> application is supposed to initialize lwip? What does lwip documentation or
> tradition say?

lwip initialization is more complex than for the typical library,
because it can be used either as pure library code with no OS
support, or as a system library with OS support.

In the first case, one would call lwip_init (as it is done presently
in libcurl for the Windows port). In the second case, one would call
tcpip_init, which spawns a separate thread which deals with every
lwip_related aspect to guarantee thread-safety of lwip.

(Disclaimer: above is AFAIU, I've only dealt with lwip for 3 months.)

>> For the time being, I've applied the following patch. Comments?
>
>> +#elif defined(USE_LWIPSOCK) && defined(HAVE_WINDOWS_H)
>> lwip_init();
>> #endif
>
> I really don't like this being dependent on the presence of windows.h. I'd
> rather we make a decision and we document that - it will still be a good idea
> to produce a short description somewhere on how to build and use libcurl with
> lwip so that future users won't have to get through all this work that you
> have!

I'm just trying to avoid having libcurl.a for SH-4 made bigger
because the code dynamically tries to deal with Windows platforms.

Perhaps more stuff can be put under conditional compilation?
Or split into different files (gnu ld can ignore objects it
doesn't need).

-- 
Regards.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2012-03-20