CURLSHOPT_UNLOCKFUNC(3)

πŸ’… CURLSHOPT_UNLOCKFUNC πŸ’…

okay so bestie, welcome to the Library Functions Manual page for CURLSHOPT_UNLOCKFUNC β€” it's the mutex unlock callback situation in libcurl, and yes it matters 🫢✨


🌸 NAME 🌸

CURLSHOPT_UNLOCKFUNC β€” mutex unlock callback ✨

✨ SYNOPSIS ✨

#include <curl/curl.h>

void unlockcb(CURL *handle, curl_lock_data data, void *clientp);

CURLSHcode curl_share_setopt(CURLSH *share, CURLSHOPT_UNLOCKFUNC, unlockcb);

πŸ¦‹ DESCRIPTION πŸ¦‹

Set a mutex unlock callback for the share object. There's a corresponding CURLSHOPT_LOCKFUNC(3) callback that gets called when the mutex is first locked β€” iconic pairing πŸ’….

The unlockcb argument has to be a pointer to a function matching the prototype shown above. The arguments your callback receives are:

  • handle β€” the currently active easy handle in use when the share object is released πŸ‘‘.
  • data β€” tells you what kind of data libcurl wants to unlock. Make sure that the callback uses a different lock for each kind of data, fr fr 🫢.
  • clientp β€” the private pointer you set with CURLSHOPT_USERDATA(3). This pointer is not used by libcurl itself πŸ™ˆ.

🌈 PROTOCOLS 🌈

This functionality affects all supported protocols. all of them, periodt 🌈✨

πŸ“ EXAMPLE πŸ“

extern void mutex_unlock(CURL *, curl_lock_data, void *);

int main(void)
{
  CURLSHcode sh;
  CURLSH *share = curl_share_init();
  sh = curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, mutex_unlock);
  if(sh)
    printf("Error: %s\n", curl_share_strerror(sh));
}

⭐ AVAILABILITY ⭐

Added in curl 7.10.3 β€” vintage but iconic πŸ’–.

πŸ’– RETURN VALUE πŸ’–

CURLSHE_OK (zero) means that the option was set properly. Non-zero means an error occurred 😭. See libcurl-errors(3) for the full list with descriptions β€” that's your error-decoder bestie.

πŸŽ€ SEE ALSO πŸŽ€


mwah πŸ’‹ this page is from libcurl, dated 2026-10-12, and it's the CURLSHOPT_UNLOCKFUNC(3) manual-page moment. bye bestie πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from