From a94d6fe706721bdc63fe4e833e07249b88b1c208 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 13 Jun 2022 18:59:45 +0000 Subject: [PATCH] version: rename threadsafe-init to threadsafe Referring to Daniel's article [1], making the init function thread-safe was the last bit to make libcurl thread-safe as a whole. So the name of the feature may as well be the more concise 'threadsafe', also telling the story that libcurl is now fully thread-safe, not just its init function. Chances are high that libcurl wants to remain so in the future, so there is little likelihood of ever needing any other distinct `threadsafe-` feature flags. For consistency we also shorten `CURL_VERSION_THREADSAFE_INIT` to `CURL_VERSION_THREADSAFE`, update its description and reference libcurl's thread safety documentation. [1]: https://daniel.haxx.se/blog/2022/06/08/making-libcurl-init-more-thread-safe/ Reviewed-by: Daniel Stenberg Reviewed-by: Jay Satiro Closes #8989 --- RELEASE-NOTES | 2 +- configure.ac | 4 ++-- docs/libcurl/curl_global_init.3 | 2 +- docs/libcurl/curl_version_info.3 | 3 ++- docs/libcurl/symbols-in-versions | 2 +- include/curl/curl.h | 5 ++--- lib/version.c | 2 +- packages/OS400/curl.inc.in | 2 +- src/tool_help.c | 2 +- tests/libtest/lib3026.c | 8 ++++---- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index e7b998f7e7..42f5f9545c 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -10,7 +10,7 @@ This release includes the following changes: o curl: add --rate to set max request rate per time unit [69] o curl: deprecate --random-file and --egd-file [12] - o curl_version_info: add CURL_VERSION_THREADSAFE_INIT [100] + o curl_version_info: add CURL_VERSION_THREADSAFE [100] o CURLINFO_CAPATH/CAINFO: get the default CA paths from libcurl [9] o lib: make curl_global_init() threadsafe when possible [101] o libssh2: add CURLOPT_SSH_HOSTKEYFUNCTION [78] diff --git a/configure.ac b/configure.ac index 359384322d..79ff336fe2 100644 --- a/configure.ac +++ b/configure.ac @@ -4262,7 +4262,7 @@ if test ${ac_cv_sizeof_curl_off_t} -gt 4; then fi if test "$tst_atomic" = "yes"; then - SUPPORT_FEATURES="$SUPPORT_FEATURES threadsafe-init" + SUPPORT_FEATURES="$SUPPORT_FEATURES threadsafe" else AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([[ @@ -4273,7 +4273,7 @@ else #endif ]]) ],[ - SUPPORT_FEATURES="$SUPPORT_FEATURES threadsafe-init" + SUPPORT_FEATURES="$SUPPORT_FEATURES threadsafe" ],[ ]) fi diff --git a/docs/libcurl/curl_global_init.3 b/docs/libcurl/curl_global_init.3 index 4d2e4ebda7..de0251e2c1 100644 --- a/docs/libcurl/curl_global_init.3 +++ b/docs/libcurl/curl_global_init.3 @@ -47,7 +47,7 @@ value unless you are familiar with it and mean to control internal operations of libcurl. This function is thread-safe since libcurl 7.84.0 if -\fIcurl_version_info(3)\fP has CURL_VERSION_THREADSAFE_INIT feature bit set +\fIcurl_version_info(3)\fP has CURL_VERSION_THREADSAFE feature bit set (most platforms). If this is not thread-safe, you must not call this function when any other diff --git a/docs/libcurl/curl_version_info.3 b/docs/libcurl/curl_version_info.3 index b253a5e214..2a27c999e4 100644 --- a/docs/libcurl/curl_version_info.3 +++ b/docs/libcurl/curl_version_info.3 @@ -206,9 +206,10 @@ libcurl was built with support for SSPI. This is only available on Windows and makes libcurl use Windows-provided functions for Kerberos, NTLM, SPNEGO and Digest authentication. It also allows libcurl to use the current user credentials without the app having to pass them on. (Added in 7.13.2) -.IP CURL_VERSION_THREADSAFE_INIT +.IP CURL_VERSION_THREADSAFE libcurl was built with thread-safety support (Atomic or SRWLOCK) to protect curl initialisation. (Added in 7.84.0) +See \fIlibcurl-thread(3)\fP .IP CURL_VERSION_TLSAUTH_SRP libcurl was built with support for TLS-SRP (in one or more of the built-in TLS backends). (Added in 7.21.4) diff --git a/docs/libcurl/symbols-in-versions b/docs/libcurl/symbols-in-versions index 2368255d4f..c590d084f1 100644 --- a/docs/libcurl/symbols-in-versions +++ b/docs/libcurl/symbols-in-versions @@ -172,7 +172,7 @@ CURL_VERSION_PSL 7.47.0 CURL_VERSION_SPNEGO 7.10.8 CURL_VERSION_SSL 7.10 CURL_VERSION_SSPI 7.13.2 -CURL_VERSION_THREADSAFE_INIT 7.84.0 +CURL_VERSION_THREADSAFE 7.84.0 CURL_VERSION_TLSAUTH_SRP 7.21.4 CURL_VERSION_UNICODE 7.72.0 CURL_VERSION_UNIX_SOCKETS 7.40.0 diff --git a/include/curl/curl.h b/include/curl/curl.h index 61670ee514..b00648e791 100644 --- a/include/curl/curl.h +++ b/include/curl/curl.h @@ -2611,7 +2611,7 @@ CURL_EXTERN void curl_free(void *p); * curl_global_init() should be invoked exactly once for each application that * uses libcurl and before any call of other libcurl functions. - * This function is thread-safe if CURL_VERSION_THREADSAFE_INIT is set in the + * This function is thread-safe if CURL_VERSION_THREADSAFE is set in the * curl_version_info_data.features flag (fetch by curl_version_info()). */ @@ -3030,8 +3030,7 @@ typedef struct curl_version_info_data curl_version_info_data; #define CURL_VERSION_UNICODE (1<<27) /* Unicode support on Windows */ #define CURL_VERSION_HSTS (1<<28) /* HSTS is supported */ #define CURL_VERSION_GSASL (1<<29) /* libgsasl is supported */ -#define CURL_VERSION_THREADSAFE_INIT (1<<30) /* curl_global_init/cleanup() are - thread-safe */ +#define CURL_VERSION_THREADSAFE (1<<30) /* libcurl API is thread-safe */ /* * NAME curl_version_info() diff --git a/lib/version.c b/lib/version.c index ba957dcdec..4672182d50 100644 --- a/lib/version.c +++ b/lib/version.c @@ -455,7 +455,7 @@ static curl_version_info_data version_info = { | CURL_VERSION_GSASL #endif #if defined(GLOBAL_INIT_IS_THREADSAFE) - | CURL_VERSION_THREADSAFE_INIT + | CURL_VERSION_THREADSAFE #endif , NULL, /* ssl_version */ diff --git a/packages/OS400/curl.inc.in b/packages/OS400/curl.inc.in index 520d373424..390c7d0514 100644 --- a/packages/OS400/curl.inc.in +++ b/packages/OS400/curl.inc.in @@ -150,7 +150,7 @@ d c X'10000000' d CURL_VERSION_GSASL... d c X'20000000' - d CURL_VERSION_THREADSAFE_INIT... + d CURL_VERSION_THREADSAFE... d c X'40000000' * d CURL_HTTPPOST_FILENAME... diff --git a/src/tool_help.c b/src/tool_help.c index b792b55ac6..75400d94c1 100644 --- a/src/tool_help.c +++ b/src/tool_help.c @@ -112,7 +112,7 @@ static const struct feat feats[] = { {"alt-svc", CURL_VERSION_ALTSVC}, {"HSTS", CURL_VERSION_HSTS}, {"gsasl", CURL_VERSION_GSASL}, - {"threadsafe-init",CURL_VERSION_THREADSAFE_INIT}, + {"threadsafe", CURL_VERSION_THREADSAFE}, }; static void print_category(curlhelp_t category) diff --git a/tests/libtest/lib3026.c b/tests/libtest/lib3026.c index 8c4a34de91..43fe33529e 100644 --- a/tests/libtest/lib3026.c +++ b/tests/libtest/lib3026.c @@ -53,9 +53,9 @@ int test(char *URL) (void) URL; ver = curl_version_info(CURLVERSION_NOW); - if((ver->features & CURL_VERSION_THREADSAFE_INIT) == 0) { + if((ver->features & CURL_VERSION_THREADSAFE) == 0) { fprintf(stderr, "%s:%d Have pthread but the " - "CURL_VERSION_THREADSAFE_INIT feature flag is not set\n", + "CURL_VERSION_THREADSAFE feature flag is not set\n", __FILE__, __LINE__); return -1; } @@ -92,9 +92,9 @@ int test(char *URL) (void)URL; ver = curl_version_info(CURLVERSION_NOW); - if((ver->features & CURL_VERSION_THREADSAFE_INIT) != 0) { + if((ver->features & CURL_VERSION_THREADSAFE) != 0) { fprintf(stderr, "%s:%d No pthread but the " - "CURL_VERSION_THREADSAFE_INIT feature flag is set\n", + "CURL_VERSION_THREADSAFE feature flag is set\n", __FILE__, __LINE__); return -1; } -- 2.47.3