CURLSHOPT_LOCKFUNC.3 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. .\" generated by cd2nroff 0.1 from CURLSHOPT_LOCKFUNC.md
  2. .TH CURLSHOPT_LOCKFUNC 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLSHOPT_LOCKFUNC \- mutex lock callback
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. void lockcb(CURL *handle, curl_lock_data data, curl_lock_access access,
  9. void *clientp);
  10. CURLSHcode curl_share_setopt(CURLSH *share, CURLSHOPT_LOCKFUNC, lockcb);
  11. .fi
  12. .SH DESCRIPTION
  13. Set a mutex lock callback for the share object, to allow it to get used by
  14. multiple threads concurrently. There is a corresponding
  15. \fICURLSHOPT_UNLOCKFUNC(3)\fP callback called when the mutex is again released.
  16. The \fIlockcb\fP argument must be a pointer to a function matching the
  17. prototype shown above. The arguments to the callback are:
  18. \fIhandle\fP is the currently active easy handle in use when the share object
  19. is intended to get used.
  20. The \fIdata\fP argument tells what kind of data libcurl wants to lock. Make
  21. sure that the callback uses a different lock for each kind of data.
  22. \fIaccess\fP defines what access type libcurl wants, shared or single.
  23. \fIclientp\fP is the private pointer you set with \fICURLSHOPT_USERDATA(3)\fP.
  24. This pointer is not used by libcurl itself.
  25. .SH PROTOCOLS
  26. This functionality affects all supported protocols
  27. .SH EXAMPLE
  28. .nf
  29. extern void mutex_lock(CURL *handle, curl_lock_data data,
  30. curl_lock_access access, void *clientp);
  31. int main(void)
  32. {
  33. CURLSHcode sh;
  34. CURLSH *share = curl_share_init();
  35. sh = curl_share_setopt(share, CURLSHOPT_LOCKFUNC, mutex_lock);
  36. if(sh)
  37. printf("Error: %s\\n", curl_share_strerror(sh));
  38. }
  39. .fi
  40. .SH AVAILABILITY
  41. Added in curl 7.10.3
  42. .SH RETURN VALUE
  43. CURLSHE_OK (zero) means that the option was set properly, non\-zero means an
  44. error occurred. See \fIlibcurl\-errors(3)\fP for the full list with
  45. descriptions.
  46. .SH SEE ALSO
  47. .BR CURLSHOPT_UNLOCKFUNC (3),
  48. .BR curl_share_cleanup (3),
  49. .BR curl_share_init (3),
  50. .BR curl_share_setopt (3)