Browse Source

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-<name>` 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
Viktor Szakats 1 year ago
parent
commit
a94d6fe706

+ 1 - 1
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]

+ 2 - 2
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

+ 1 - 1
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

+ 2 - 1
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)

+ 1 - 1
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

+ 2 - 3
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()

+ 1 - 1
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 */

+ 1 - 1
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...

+ 1 - 1
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)

+ 4 - 4
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;
   }