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