cURL / Mailing Lists / curl-library / Single Mail

curl-library

Queries regarding the use of curl easy handle across multiple threads (using mutex to synchronize).

From: ameya agnihotri <ameyaagnihotri22_at_gmail.com>
Date: Tue, 5 May 2009 22:43:59 +0530

Hi All,
Following is the scenario:

1. I have multi threaded C application.
2. I have a curl handle(curl_easy_init() initialization is done during
application startup), and a mutex associated with it.
3. Every thread acquires a lock, and then calls curl_easy_setopt() and sets
parameters.
Please note that CURLOPT_URL parameter might differ from thread to thread.
4. This handle is added to curl_multi interface using
curl_multi_add_handle() , and curl_multi_perform() is called.
(I use multiple curls handles each associated with a mutex . Hence
curl_multi interface is used).
5. Later, using curl_multi_remove_handle(), the handle is removed.
6. Also, mutex is released and the handle is ready of further use.

Problem: I am experiencing ocassional crash after multiple thread runs.

I have following questions:
1. Is the above usage valid for libcurl on linux?
2. Is there any restriction on calling curl_easy_setopt() , after
curl_multi_perform() ?

Following is the back trace obtained from coredump using gdb:
#0 0x00b4c7a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
#1 0x00b927a5 in raise () from /lib/tls/libc.so.6
#2 0x00b94209 in abort () from /lib/tls/libc.so.6
#3 0x00bc6a1a in __libc_message () from /lib/tls/libc.so.6
#4 0x00bcd2bf in _int_free () from /lib/tls/libc.so.6
#5 0x00bcd63a in free () from /lib/tls/libc.so.6
#6 0x0060dd74 in setstropt () from /usr/local/lib/libcurl.so.4
#7 0x0060f8ea in Curl_setopt () from /usr/local/lib/libcurl.so.4
#8 0x0061f06b in curl_easy_setopt () from /usr/local/lib/libcurl.so.4

Curl Version details:
curl 7.19.2 (i686-pc-linux-gnu)

Thanks & Regards,
Ameya
Received on 2009-05-05