CURLSHOPT_LOCKFUNC.3 2.7 KB

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