cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: using libcurl in an enterprise application server

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Fri, 3 Oct 2014 22:34:54 +0200

On Fri, Oct 03, 2014 at 10:12:25AM -0400, Michael Mueller wrote:
> We are attempting to use libcurl in an app running under the control
> of a enterprise application server.Our app runs in a thread. Our app's
> call to "curl_global_init(CURL_GLOBAL_ALL)" hangs. We do not have
> access to the main() of the enterprise app server.
>
> However, when our app-in-a-thread uses
> "popen(INVOKE_A_SCRIPT_WITH_CURL_CMDS)", we happily POST requests and
> get responses. We think the key to success is that popen spawns a
> child process that keeps things independent of the ent app server.
>
> We would prefer to implement using libcurl.
>
> Any thoughts, suggestions, admonishments, or questions to help push us
> along would be appreciated.

As documented, curl_global_init may not be called from a thread but from the
main function before any threads are running. Ideally, you would be able to
hook into an initialization function of some sort that's called before the app
server starts your thread. Failing that, perhaps you can play some games with
the dynamic loader and use __attribute__ ((constructor)) (or the non-gcc
equivalent) to force your initialization function and curl_global_init to run
before the app server even starts.

>>> Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-10-03