Buy commercial curl support. We
help you work out your issues, debug your libcurl applications, use the API,
port to new platforms, add new features and more. With a team lead by the
curl founder Daniel himself.
Question about thread safety of shared interface handle
- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]
From: Dmitry Karpov via curl-library <curl-library_at_lists.haxx.se>
Date: Thu, 5 Sep 2024 19:13:50 +0000
Hi folks,
I think I am confused about thread safety provided by the shared interface handle with thread-safe lock function option.
As I understood from the documentation, a lock function with proper thread locking mechanism (mutexes etc.) is supposed to provide thread-safe usage model for a shared interface handle used by different easy handles in multiple threads.
At the same time, as I can see in the https://curl.se/libcurl/c/CURLSHOPT_SHARE.html:
CURL_LOCK_DATA_COOKIE:
It is not supported to share cookies between multiple concurrent threads.
CURL_LOCK_DATA_SSL_SESSION
It is not supported to share SSL sessions between multiple concurrent threads.
CURL_LOCK_DATA_CONNECT
It is not supported to share connections between multiple concurrent threads.
So, I am wondering, if different easy handles running in different threads (and using different multi handles) may use the same shared interface handle with a thread-safe locking function?
If yes, then what the " It is not supported to share ... between multiple concurrent threads" warnings means?
If not, then what is the purpose of the locking function then?
I fully understand that multi and easy handles may not be used by multiple threads simultaneously,
but I expect that the share interface is supposed to allow sharing things between handles in different threads if these easy/multi handles are not accessed at the same time.
It would be very helpful to get a clarification on this matter to avoid trickly multi-threading issues.
Thanks,
Dmitry Karpov
Date: Thu, 5 Sep 2024 19:13:50 +0000
Hi folks,
I think I am confused about thread safety provided by the shared interface handle with thread-safe lock function option.
As I understood from the documentation, a lock function with proper thread locking mechanism (mutexes etc.) is supposed to provide thread-safe usage model for a shared interface handle used by different easy handles in multiple threads.
At the same time, as I can see in the https://curl.se/libcurl/c/CURLSHOPT_SHARE.html:
CURL_LOCK_DATA_COOKIE:
It is not supported to share cookies between multiple concurrent threads.
CURL_LOCK_DATA_SSL_SESSION
It is not supported to share SSL sessions between multiple concurrent threads.
CURL_LOCK_DATA_CONNECT
It is not supported to share connections between multiple concurrent threads.
So, I am wondering, if different easy handles running in different threads (and using different multi handles) may use the same shared interface handle with a thread-safe locking function?
If yes, then what the " It is not supported to share ... between multiple concurrent threads" warnings means?
If not, then what is the purpose of the locking function then?
I fully understand that multi and easy handles may not be used by multiple threads simultaneously,
but I expect that the share interface is supposed to allow sharing things between handles in different threads if these easy/multi handles are not accessed at the same time.
It would be very helpful to get a clarification on this matter to avoid trickly multi-threading issues.
Thanks,
Dmitry Karpov
-- Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library Etiquette: https://curl.se/mail/etiquette.htmlReceived on 2024-09-05