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