cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: block process when call curl_easy_perform

From: guilherme linhares <guilherme.linhares_at_digitro.com.br>
Date: Wed, 19 Oct 2011 17:18:45 -0200
Hello Dan,

Well, i change my code to use libcurl's multi interface.
Now i call a new thread to do:

- curl_easy_init();
- curl_easy_setopt();
- curl_multi_add_handle();
- curl_multi_perform();
- curl_multi_fdset();
- curl_easy_getinfo();

In this scenario when i add 2 or more handles in the same time and do curl_multi_perform();

I get this errors in the log

== Info: Expire cleared
== Info: Connection #0 to host 192.168.160.158 left intact
== Info: SSLv?, Unknown (2):
== Info: SSL read: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number, errno 0
== Info: SSL read: error:140D2081:SSL routines:TLS1_ENC:block cipher pad is wrong, errno 0
== Info: Expire cleared
== Info: Empty reply from server
== Info: Connection #1 to host 192.168.160.158 left intact
== Info: Internal error removing splay node = 1


I use libcurl 7.19.4 openssl-0.9.7m

Best regards

Guilherme Linhares



Em 13/10/2011 20:20, Dan Fandrich escreveu:
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


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