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 <curl-library_at_cool.haxx.se>
Date: Tue, 4 Jun 2019 12:26:14 -0400

Hi,

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

https://curl.haxx.se/libcurl/c/curl_share_setopt.html

says:

> 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:

https://curl.haxx.se/mail/lib-2006-01/0217.html

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

https://github.com/curl/curl/blob/2f44e94efb3df8e50bb2ddbc4ec6b569a6424517/lib/url.c

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
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2019-06-04