curl_share_setopt(3) | libcurl Manual | curl_share_setopt(3) |
curl_share_setopt - Set options for a shared object
#include <curl/curl.h>
CURLSHcode curl_share_setopt(CURLSH *share, CURLSHoption option, parameter);
Set the option to parameter for the given share.
void lock_function(CURL *handle, curl_lock_data data, curl_lock_access access, void *userptr);
The data argument tells what kind of data libcurl wants to lock. Make sure that the callback uses a different lock for each kind of data.
access defines what access type libcurl wants, shared or single.
userptr is the pointer you set with CURLSHOPT_USERDATA.
void unlock_function(CURL *handle, curl_lock_data data, void *userptr);
data defines what data libcurl wants to unlock, and you must make sure that only one lock is given at any time for each kind of data.
userptr is the pointer you set with CURLSHOPT_USERDATA.
Note that due to a known bug, it is not safe to share connections this way between multiple concurrent threads.
Connections that are used for HTTP/1.1 Pipelining or HTTP/2 multiplexing only get additional transfers added to them if the existing connection is held by the same multi or easy handle. libcurl does not support doing HTTP/2 streams in different threads using a shared connection.
Support for CURL_LOCK_DATA_CONNECT was added in 7.57.0, but the symbol existed before this.
Note that when you use the multi interface, all easy handles added to the same multi handle will share connection cache by default without using this option.
CURL_LOCK_DATA_PSL exists since 7.61.0.
Note that when you use the multi interface, all easy handles added to the same multi handle will share PSL cache by default without using this option.
CURLSHE_OK (zero) means that the option was set properly, non-zero means an error occurred as <curl/curl.h> defines. See the libcurl-errors.3 man page for the full list with descriptions.
November 4, 2020 | libcurl 7.74.0 |