cURL / Mailing Lists / curl-library / Single Mail

curl-library

thread safety.

From: Evgeny Turnaev <turnaev.e_at_gmail.com>
Date: Wed, 17 Jul 2013 15:45:52 +0400

Dear All.
  I have a question regarding to thread safety.
  My libcurl usage scenario:
1) curl_global_init() // in main thread
2) create thread and inside this threaad worker function:
    cm = curl_multi_init()
    eh = curl_easy_init()
    curl_multi_add_handle(cm, eh)
3) all the call related to transfer: curl_multi_perform(),
curl_multi_wait() and curl_multi_info_read()
    are in the same thread where curl_multi_init() was called.
4) after multi_info_read() indicates that transfer complete i remove
   easy_handle from multi and want to pass it to main thread to read
response code,
   headers, body.
5) after main thread read all the properties of easy_handle, using
only curl_easy_getinfo() function
    it will pass easy_handle back to thread where all the io is going
(therad that called curl_multi_init())
    and when easy_handle is selected again for usage - it is reseted.

(all passing of easy_curl between threads is made under mutex)

The page http://curl.haxx.se/libcurl/features.html state:
"""Never share libcurl handles between multiple threads. You should
only use one handle in one single thread at any given time"""
But i feel like curl_easy_getinfo() does not modify anyhow easy_handle
and thus can be used from other threads as long as handle is not
processed.

The question basically is: Does calling curl_easy_getinfo() from other
(than created easy handle) thread in my scenario (calling getinfo()
after transfer complete and handle removed from multi interface) falls
into category of handle usage and thus should obey the statement from
page.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-07-17