curl_share_setopt.3 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.haxx.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" **************************************************************************
  22. .TH curl_share_setopt 3 "8 Aug 2003" "libcurl 7.10.7" "libcurl Manual"
  23. .SH NAME
  24. curl_share_setopt - Set options for a shared object
  25. .SH SYNOPSIS
  26. .B #include <curl/curl.h>
  27. .sp
  28. CURLSHcode curl_share_setopt(CURLSH *share, CURLSHoption option, parameter);
  29. .ad
  30. .SH DESCRIPTION
  31. Set the \fIoption\fP to \fIparameter\fP for the given \fIshare\fP.
  32. .SH OPTIONS
  33. .IP CURLSHOPT_LOCKFUNC
  34. The \fIparameter\fP must be a pointer to a function matching the following
  35. prototype:
  36. void lock_function(CURL *handle, curl_lock_data data, curl_lock_access access,
  37. void *userptr);
  38. The \fIdata\fP argument tells what kind of data libcurl wants to lock. Make
  39. sure that the callback uses a different lock for each kind of data.
  40. \fIaccess\fP defines what access type libcurl wants, shared or single.
  41. \fIuserptr\fP is the pointer you set with \fICURLSHOPT_USERDATA\fP.
  42. .IP CURLSHOPT_UNLOCKFUNC
  43. The \fIparameter\fP must be a pointer to a function matching the following
  44. prototype:
  45. void unlock_function(CURL *handle, curl_lock_data data, void *userptr);
  46. \fIdata\fP defines what data libcurl wants to unlock, and you must make sure
  47. that only one lock is given at any time for each kind of data.
  48. \fIuserptr\fP is the pointer you set with \fICURLSHOPT_USERDATA\fP.
  49. .IP CURLSHOPT_SHARE
  50. The \fIparameter\fP specifies a type of data that should be shared. This may
  51. be set to one of the values described below.
  52. .RS
  53. .IP CURL_LOCK_DATA_COOKIE
  54. Cookie data will be shared across the easy handles using this shared object.
  55. Note that this does not activate an easy handle's cookie handling. You can do
  56. that separately by using \fICURLOPT_COOKIEFILE(3)\fP for example.
  57. .IP CURL_LOCK_DATA_DNS
  58. Cached DNS hosts will be shared across the easy handles using this shared
  59. object. Note that when you use the multi interface, all easy handles added to
  60. the same multi handle will share DNS cache by default without using this
  61. option.
  62. .IP CURL_LOCK_DATA_SSL_SESSION
  63. SSL session IDs will be shared across the easy handles using this shared
  64. object. This will reduce the time spent in the SSL handshake when reconnecting
  65. to the same server. Note SSL session IDs are reused within the same easy handle
  66. by default. Note this symbol was added in 7.10.3 but was not implemented until
  67. 7.23.0.
  68. .IP CURL_LOCK_DATA_CONNECT
  69. Put the connection cache in the share object and make all easy handles using
  70. this share object share the connection cache.
  71. Note that due to a known bug, it is not safe to share connections this way
  72. between multiple concurrent threads.
  73. Connections that are used for HTTP/1.1 Pipelining or HTTP/2 multiplexing only
  74. get additional transfers added to them if the existing connection is held by
  75. the same multi or easy handle. libcurl does not support doing HTTP/2 streams
  76. in different threads using a shared connection.
  77. Support for \fBCURL_LOCK_DATA_CONNECT\fP was added in 7.57.0, but the symbol
  78. existed before this.
  79. Note that when you use the multi interface, all easy handles added to the same
  80. multi handle will share connection cache by default without using this option.
  81. .IP CURL_LOCK_DATA_PSL
  82. The Public Suffix List stored in the share object is made available to all
  83. easy handle bound to the later. Since the Public Suffix List is periodically
  84. refreshed, this avoids updates in too many different contexts.
  85. \fBCURL_LOCK_DATA_PSL\fP exists since 7.61.0.
  86. Note that when you use the multi interface, all easy handles added to the same
  87. multi handle will share PSL cache by default without using this option.
  88. .RE
  89. .IP CURLSHOPT_UNSHARE
  90. This option does the opposite of \fICURLSHOPT_SHARE\fP. It specifies that
  91. the specified \fIparameter\fP will no longer be shared. Valid values are
  92. the same as those for \fICURLSHOPT_SHARE\fP.
  93. .IP CURLSHOPT_USERDATA
  94. The \fIparameter\fP allows you to specify a pointer to data that will be passed
  95. to the lock_function and unlock_function each time it is called.
  96. .SH RETURN VALUE
  97. CURLSHE_OK (zero) means that the option was set properly, non-zero means an
  98. error occurred as \fI<curl/curl.h>\fP defines. See the \fIlibcurl-errors.3\fP
  99. man page for the full list with descriptions.
  100. .SH "SEE ALSO"
  101. .BR curl_share_cleanup "(3), " curl_share_init "(3)"