1curl_share_setopt(3)            libcurl Manual            curl_share_setopt(3)
2
3
4

NAME

6       curl_share_setopt - Set options for a shared object
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLSHcode curl_share_setopt(CURLSH *share, CURLSHoption option, param‐
12       eter);
13

DESCRIPTION

15       Set the option to parameter for the given share.
16

OPTIONS

18       CURLSHOPT_LOCKFUNC
19              The parameter must be a pointer to a function matching the  fol‐
20              lowing prototype:
21
22              void    lock_function(CURL    *handle,    curl_lock_data   data,
23              curl_lock_access access, void *userptr);
24
25              The data argument tells what kind of data libcurl wants to lock.
26              Make  sure that the callback uses a different lock for each kind
27              of data.
28
29              access defines what access type libcurl wants, shared or single.
30
31              userptr is the pointer you set with CURLSHOPT_USERDATA.
32
33       CURLSHOPT_UNLOCKFUNC
34              The parameter must be a pointer to a function matching the  fol‐
35              lowing prototype:
36
37              void  unlock_function(CURL  *handle,  curl_lock_data  data, void
38              *userptr);
39
40              data defines what data libcurl wants to  unlock,  and  you  must
41              make  sure that only one lock is given at any time for each kind
42              of data.
43
44              userptr is the pointer you set with CURLSHOPT_USERDATA.
45
46       CURLSHOPT_SHARE
47              The parameter specifies a type of data that  should  be  shared.
48              This may be set to one of the values described below.
49
50              CURL_LOCK_DATA_COOKIE
51                     Cookie  data will be shared across the easy handles using
52                     this shared object.
53
54              CURL_LOCK_DATA_DNS
55                     Cached DNS hosts will be shared across the  easy  handles
56                     using  this  shared  object.  Note  that when you use the
57                     multi interface, all easy handles added to the same multi
58                     handle will share DNS cache by default without using this
59                     option.
60
61              CURL_LOCK_DATA_SSL_SESSION
62                     SSL session IDs will be shared across  the  easy  handles
63                     using this shared object. This will reduce the time spent
64                     in the  SSL  handshake  when  reconnecting  to  the  same
65                     server.  Note  SSL session IDs are reused within the same
66                     easy handle by default. Note this  symbol  was  added  in
67                     7.10.3 but was not implemented until 7.23.0.
68
69              CURL_LOCK_DATA_CONNECT
70                     Put the connection cache in the share object and make all
71                     easy handles using this share object share the connection
72                     cache.  Using this, you can for example do multi-threaded
73                     libcurl use with one handle in each thread, and yet  have
74                     a  shared pool of unused connections and this way get way
75                     better connection re-use than if  you  use  one  separate
76                     pool in each thread.
77
78                     Connections  that  are  used  for  HTTP/1.1 Pipelining or
79                     HTTP/2 multiplexing only get additional  transfers  added
80                     to  them  if  the existing connection is held by the same
81                     multi or easy handle.  libcurl  does  not  support  doing
82                     HTTP/2  streams  in different threads using a shared con‐
83                     nection.
84
85                     Support for CURL_LOCK_DATA_CONNECT was added  in  7.57.0,
86                     but the symbol existed before this.
87
88                     Note that when you use the multi interface, all easy han‐
89                     dles added to the same multi handle will share connection
90                     cache by default without using this option.
91
92              CURL_LOCK_DATA_PSL
93                     The Public Suffix List stored in the share object is made
94                     available to all easy handle bound to  the  later.  Since
95                     the  Public  Suffix  List is periodically refreshed, this
96                     avoids updates in too many different contexts.
97
98                     CURL_LOCK_DATA_PSL exists since 7.61.0.
99
100                     Note that when you use the multi interface, all easy han‐
101                     dles  added to the same multi handle will share PSL cache
102                     by default without using this option.
103
104       CURLSHOPT_UNSHARE
105              This option does the opposite of CURLSHOPT_SHARE.  It  specifies
106              that  the  specified  parameter  will no longer be shared. Valid
107              values are the same as those for CURLSHOPT_SHARE.
108
109       CURLSHOPT_USERDATA
110              The parameter allows you to specify a pointer to data that  will
111              be  passed to the lock_function and unlock_function each time it
112              is called.
113

RETURN VALUE

115       CURLSHE_OK (zero) means that the  option  was  set  properly,  non-zero
116       means  an  error  occurred  as  <curl/curl.h> defines. See the libcurl-
117       errors.3 man page for the full list with descriptions.
118

SEE ALSO

120       curl_share_cleanup(3), curl_share_init(3)
121
122
123
124libcurl 7.66.0                   June 04, 2019            curl_share_setopt(3)
Impressum