curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

CURLSHOPT_LOCKFUNC callback requirements.

From: Carlos ORyan via curl-library <>
Date: Tue, 4 Jun 2019 12:26:14 -0400


First, thanks for the excellent product and documentation. This is
mostly a question about whether I am reading the documentation


> data defines what data libcurl wants to lock, and you must make sure that only one lock
> is given at any time for each kind of data.

That requirement is met by giving the *same* lock to different kinds
of data. Did I interpret the doc correctly, or should I use a
different lock for each kind of data (just the same lock for the same
CURLSH* and data kind, and one would expect).

I cannot find any further documentation, except this from the archives:

which suggests a single lock is fine. However I (or rather one of my
users) reported a deadlock because the code here:

Would grab the same lock around lines 997 and 1046. And between my
reading of the documentation and what the code does I am inclined to
believe the code :-)

I guess the bottom line is: should I use different locks for different
kinds of data in the same CURLSH* handle? And if so, may I suggest
that the documentation could be improved to say:

> ... When using multiple kinds of data in a CURLSH you must make sure that your callback
> uses a different lock for each kind of data. With that constraint in mind, use a single lock a
> time for each CURLSH and kind of data.

Thanks in advance,

Carlos O'Ryan
Cloud C++ Client Libraries
#include <cute.quote> // TODO(coryan@) actually pick a quote
Received on 2019-06-04