1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLSHOPT_UNLOCKFUNC
5Section: 3
6Source: libcurl
7See-also:
8  - CURLSHOPT_LOCKFUNC (3)
9  - curl_share_cleanup (3)
10  - curl_share_init (3)
11  - curl_share_setopt (3)
12Protocol:
13  - All
14Added-in: 7.10.3
15---
16
17# NAME
18
19CURLSHOPT_UNLOCKFUNC - mutex unlock callback
20
21# SYNOPSIS
22
23~~~c
24#include <curl/curl.h>
25
26void unlockcb(CURL *handle, curl_lock_data data, void *clientp);
27
28CURLSHcode curl_share_setopt(CURLSH *share, CURLSHOPT_UNLOCKFUNC, unlockcb);
29~~~
30
31# DESCRIPTION
32
33Set a mutex unlock callback for the share object. There is a corresponding
34CURLSHOPT_LOCKFUNC(3) callback called when the mutex is first locked.
35
36The *unlockcb* argument must be a pointer to a function matching the
37prototype shown above. The arguments to the callback are:
38
39*handle* is the currently active easy handle in use when the share object
40is released.
41
42The *data* argument tells what kind of data libcurl wants to unlock. Make
43sure that the callback uses a different lock for each kind of data.
44
45*clientp* is the private pointer you set with CURLSHOPT_USERDATA(3).
46This pointer is not used by libcurl itself.
47
48# %PROTOCOLS%
49
50# EXAMPLE
51
52~~~c
53extern void mutex_unlock(CURL *, curl_lock_data, void *);
54
55int main(void)
56{
57  CURLSHcode sh;
58  CURLSH *share = curl_share_init();
59  sh = curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, mutex_unlock);
60  if(sh)
61    printf("Error: %s\n", curl_share_strerror(sh));
62}
63~~~
64
65# %AVAILABILITY%
66
67# RETURN VALUE
68
69CURLSHE_OK (zero) means that the option was set properly, non-zero means an
70error occurred. See libcurl-errors(3) for the full list with
71descriptions.
72