2
0

CURLSHOPT_LOCKFUNC.3 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2021, 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.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 CURLSHOPT_LOCKFUNC 3 "8 Aug 2003" "libcurl 7.10.7" "libcurl Manual"
  23. .SH NAME
  24. CURLSHOPT_LOCKFUNC - mutex lock callback
  25. .SH SYNOPSIS
  26. .nf
  27. #include <curl/curl.h>
  28. void lockcb(CURL *handle, curl_lock_data data, curl_lock_access access,
  29. void *userptr);
  30. CURLSHcode curl_share_setopt(CURLSH *share, CURLSHOPT_LOCKFUNC, lockcb);
  31. .fi
  32. .SH DESCRIPTION
  33. Set a mutex lock callback for the share object, to allow it to get used by
  34. multiple threads concurrently. There's a corresponding
  35. \fICURLSHOPT_UNLOCKFUNC(3)\fP callback called when the mutex is again released.
  36. The \fIlockcb\fP argument must be a pointer to a function matching the
  37. prototype shown above. The arguments to the callback are:
  38. \fIhandle\fP is the currently active easy handle in use when the share object
  39. is intended to get used.
  40. The \fIdata\fP argument tells what kind of data libcurl wants to lock. Make
  41. sure that the callback uses a different lock for each kind of data.
  42. \fIaccess\fP defines what access type libcurl wants, shared or single.
  43. \fIuserptr\fP is the private pointer you set with \fICURLSHOPT_USERDATA\fP.
  44. This pointer is not used by libcurl itself.
  45. .SH PROTOCOLS
  46. All
  47. .SH EXAMPLE
  48. .nf
  49. CURLSHcode sh;
  50. share = curl_share_init();
  51. sh = curl_share_setopt(share, CURLSHOPT_LOCKFUNC, mutex_lock);
  52. if(sh)
  53. printf("Error: %s\\n", curl_share_strerror(sh));
  54. .fi
  55. .SH AVAILABILITY
  56. Added in 7.10
  57. .SH RETURN VALUE
  58. CURLSHE_OK (zero) means that the option was set properly, non-zero means an
  59. error occurred. See \fIlibcurl-errors(3)\fP for the full list with
  60. descriptions.
  61. .SH "SEE ALSO"
  62. .BR CURLSHOPT_UNLOCKFUNC "(3), "
  63. .BR curl_share_setopt "(3), " curl_share_cleanup "(3), " curl_share_init "(3)"