cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: block process when call curl_easy_perform

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Thu, 13 Oct 2011 16:20:32 -0700

On Thu, Oct 13, 2011 at 10:04:17AM -0300, guilherme linhares wrote:
> I'm having some problems with the use of libcurl.
> In my program I have some internal processes (control, configuration, calls [
> thread N])
> I created an environment for communication between these processes. In this
> environment called the function curl_global_ini and declared my array with
> information about the handles (struct).
> I use the libcurl functions in the process (call [N]).
> When I call the function res = curl_easy_perform (curl), the communication
> environment is blocked.

Correct; curl_easy_perform blocks until the transfer has been performed.

> This is expected? There should be thread-safe?

You'll have to read the documentation for the details, but the short
answer is that yes, libcurl is thread safe, as long as each handle is only
accessed from one thread at a time and any locking requirements have been
addressed for the SSL library in use.

> I have to use a exclusive thread for this function?

It depends on what you're trying to accomplish. If curl_easy_perform()
blocking is an issue to the rest of the program, then that's one valid
approach to getting around it. Another approach is to use libcurl's
multi interface to perform the transfer in a non-blocking manner within a
single program thread.

>>> Dan

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-10-14