mirror of
https://github.com/curl/curl.git
synced 2026-07-24 11:37:21 +03:00
badwords: catch and fix threading-related words
Also: - sync newlines between the two threaded examples. Closes #20001
This commit is contained in:
parent
8dadff9434
commit
61273f5812
25 changed files with 45 additions and 38 deletions
3
.github/scripts/badwords.txt
vendored
3
.github/scripts/badwords.txt
vendored
|
|
@ -10,6 +10,9 @@ tool chain:toolchain
|
|||
tool-chain:toolchain
|
||||
wild-card:wildcard
|
||||
wild card:wildcard
|
||||
\bthread ?safe[^."t]:thread-safe
|
||||
\bthread ?unsafe[^."t]:thread-unsafe
|
||||
multi ?thread:multi-thread
|
||||
\bit's:it is
|
||||
aren't:are not
|
||||
can't:cannot
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ This release includes the following bugfixes:
|
|||
o example: fix formatting nits [232]
|
||||
o examples/crawler: fix variable [92]
|
||||
o examples/multi-uv: fix invalid req->data access [177]
|
||||
o examples/multithread: fix race condition [101]
|
||||
o examples/threaded: fix race condition [101]
|
||||
o examples: fix minor typo [203]
|
||||
o examples: make functions/data static where missing [139]
|
||||
o examples: tidy-up headers and includes [138]
|
||||
|
|
|
|||
2
docs/examples/.gitignore
vendored
2
docs/examples/.gitignore
vendored
|
|
@ -79,7 +79,6 @@ multi-legacy
|
|||
multi-post
|
||||
multi-single
|
||||
multi-uv
|
||||
multithread
|
||||
netrc
|
||||
parseurl
|
||||
persistent
|
||||
|
|
@ -123,6 +122,7 @@ smtp-tls
|
|||
smtp-vrfy
|
||||
sslbackend
|
||||
synctime
|
||||
threaded
|
||||
threaded-ssl
|
||||
unixsocket
|
||||
url2file
|
||||
|
|
|
|||
|
|
@ -146,8 +146,8 @@ check_PROGRAMS = \
|
|||
COMPLICATED_MAY_BUILD = \
|
||||
cacertinmem.c \
|
||||
multi-uv.c \
|
||||
multithread.c \
|
||||
sessioninfo.c \
|
||||
threaded.c \
|
||||
threaded-ssl.c \
|
||||
usercertinmem.c
|
||||
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ static int my_trace(CURL *curl, curl_infotype type,
|
|||
known_offset = 1;
|
||||
}
|
||||
secs = epoch_offset + tv.tv_sec;
|
||||
now = localtime(&secs); /* not thread safe but we do not care */
|
||||
now = localtime(&secs); /* not thread-safe but we do not care */
|
||||
snprintf(timebuf, sizeof(timebuf), "%02d:%02d:%02d.%06ld",
|
||||
now->tm_hour, now->tm_min, now->tm_sec, (long)tv.tv_usec);
|
||||
|
||||
|
|
|
|||
|
|
@ -22,8 +22,8 @@
|
|||
*
|
||||
***************************************************************************/
|
||||
/* <DESC>
|
||||
* A multi threaded application that uses a progress bar to show
|
||||
* status. It uses Gtk+ to make a smooth pulse.
|
||||
* A multi-threaded application that uses a progress bar to show
|
||||
* status. It uses Gtk+ to make a smooth pulse.
|
||||
* </DESC>
|
||||
*/
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
/* A multi-threaded example that uses pthreads and fetches 4 remote files at
|
||||
* once over HTTPS.
|
||||
*
|
||||
* Recent versions of OpenSSL and GnuTLS are thread safe by design, assuming
|
||||
* Recent versions of OpenSSL and GnuTLS are thread-safe by design, assuming
|
||||
* support for the underlying OS threading API is built-in. Older revisions
|
||||
* of this example demonstrated locking callbacks for the SSL library, which
|
||||
* are no longer necessary. An older revision with callbacks can be found at
|
||||
|
|
@ -40,7 +40,9 @@
|
|||
/* Also requires TLS support to run */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#define NUMT 4
|
||||
|
|
|
|||
|
|
@ -107,6 +107,8 @@ int main(void)
|
|||
pthread_join(tid[i], NULL);
|
||||
fprintf(stderr, "Thread %d terminated\n", i);
|
||||
}
|
||||
|
||||
curl_global_cleanup();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -40,7 +40,7 @@ If this is not thread-safe, you must not call this function when any other
|
|||
thread in the program (i.e. a thread sharing the same memory) is running.
|
||||
This does not just mean no other thread that is using libcurl. Because
|
||||
curl_global_cleanup(3) calls functions of other libraries that are
|
||||
similarly thread unsafe, it could conflict with any other thread that uses
|
||||
similarly thread-unsafe, it could conflict with any other thread that uses
|
||||
these other libraries.
|
||||
|
||||
See the description in libcurl(3) of global environment requirements for
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ If this is not thread-safe (the bit mentioned above is not set), you must not
|
|||
call this function when any other thread in the program (i.e. a thread sharing
|
||||
the same memory) is running. This does not just mean no other thread that is
|
||||
using libcurl. Because curl_global_init(3) calls functions of other libraries
|
||||
that are similarly thread unsafe, it could conflict with any other thread that
|
||||
that are similarly thread-unsafe, it could conflict with any other thread that
|
||||
uses these other libraries.
|
||||
|
||||
If you are initializing libcurl from a Windows DLL you should not initialize
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ If this is not thread-safe, you must not call this function when any other
|
|||
thread in the program (i.e. a thread sharing the same memory) is running. This
|
||||
does not just mean no other thread that is using libcurl. Because
|
||||
curl_global_init(3) may call functions of other libraries that are similarly
|
||||
thread unsafe, it could conflict with any other thread that uses these other
|
||||
thread-unsafe, it could conflict with any other thread that uses these other
|
||||
libraries.
|
||||
|
||||
If you are initializing libcurl from a Windows DLL you should not initialize
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ libcurl-thread - libcurl thread safety
|
|||
|
||||
# Multi-threading with libcurl
|
||||
|
||||
libcurl is thread safe but has no internal thread synchronization. You may have
|
||||
libcurl is thread-safe but has no internal thread synchronization. You may have
|
||||
to provide your own locking should you meet any of the thread safety exceptions
|
||||
below.
|
||||
|
||||
|
|
@ -84,10 +84,10 @@ the former signal handler while another thread should still ignore it.
|
|||
# Name resolving
|
||||
|
||||
The **gethostbyname** or **getaddrinfo** and other name resolving system
|
||||
calls used by libcurl are provided by your operating system and must be thread
|
||||
safe. It is important that libcurl can find and use thread safe versions of
|
||||
these and other system calls, as otherwise it cannot function fully thread
|
||||
safe. Some operating systems are known to have faulty thread
|
||||
calls used by libcurl are provided by your operating system and must be
|
||||
thread-safe. It is important that libcurl can find and use thread-safe versions
|
||||
of these and other system calls, as otherwise it cannot function fully
|
||||
thread-safe. Some operating systems are known to have faulty thread
|
||||
implementations. We have previously received problem reports on *BSD (at least
|
||||
in the past, they may be working fine these days). Some operating systems that
|
||||
are known to have solid and working thread support are Linux, Solaris and
|
||||
|
|
@ -110,7 +110,7 @@ libcurl(3) section **GLOBAL CONSTANTS**.
|
|||
# Memory functions
|
||||
|
||||
These functions, provided either by your operating system or your own
|
||||
replacements, must be thread safe. You can use curl_global_init_mem(3)
|
||||
replacements, must be thread-safe. You can use curl_global_init_mem(3)
|
||||
to set your own replacement memory functions.
|
||||
|
||||
# Non-safe functions
|
||||
|
|
|
|||
|
|
@ -272,7 +272,7 @@ all the details needed to get the file moved from one machine to another.
|
|||
|
||||
# Multi-threading Issues
|
||||
|
||||
libcurl is thread safe but there are a few exceptions. Refer to
|
||||
libcurl is thread-safe but there are a few exceptions. Refer to
|
||||
libcurl-thread(3) for more information.
|
||||
|
||||
# When It does not Work
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ the same, on any of the platforms it compiles and builds on.
|
|||
|
||||
# THREADS
|
||||
|
||||
libcurl is thread safe but there are a few exceptions. Refer to
|
||||
libcurl is thread-safe but there are a few exceptions. Refer to
|
||||
libcurl-thread(3) for more information.
|
||||
|
||||
# PERSISTENT CONNECTIONS
|
||||
|
|
@ -176,7 +176,7 @@ The global constant functions are thread-safe since libcurl 7.84.0 if
|
|||
curl_version_info(3) has the CURL_VERSION_THREADSAFE feature bit set
|
||||
(most platforms). Read libcurl-thread(3) for thread safety guidelines.
|
||||
|
||||
If the global constant functions are *not thread safe*, then you must
|
||||
If the global constant functions are *not thread-safe*, then you must
|
||||
not call them when any other thread in the program is running. It
|
||||
is not good enough that no other thread is using libcurl at the time,
|
||||
because these functions internally call similar functions of other
|
||||
|
|
@ -184,7 +184,7 @@ libraries, and those functions are similarly thread-unsafe. You cannot
|
|||
generally know what these libraries are, or whether other threads are
|
||||
using them.
|
||||
|
||||
If the global constant functions are *not thread safe*, then the basic rule
|
||||
If the global constant functions are *not thread-safe*, then the basic rule
|
||||
for constructing a program that uses libcurl is this: Call
|
||||
curl_global_init(3), with a *CURL_GLOBAL_ALL* argument, immediately
|
||||
after the program starts, while it is still only one thread and before it uses
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ int main(void)
|
|||
if(curl) {
|
||||
CURLcode ret;
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
|
||||
/* switch off the use of a global, thread unsafe, cache */
|
||||
/* switch off the use of a global, thread-unsafe, cache */
|
||||
curl_easy_setopt(curl, CURLOPT_DNS_USE_GLOBAL_CACHE, 0L);
|
||||
ret = curl_easy_perform(curl);
|
||||
curl_easy_cleanup(curl);
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ CURL_EXTERN CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ...);
|
|||
* Creates a new curl session handle with the same options set for the handle
|
||||
* passed in. Duplicating a handle could only be a matter of cloning data and
|
||||
* options, internal state info and things like persistent connections cannot
|
||||
* be transferred. It is useful in multithreaded applications when you can run
|
||||
* be transferred. It is useful in multi-threaded applications when you can run
|
||||
* curl_easy_duphandle() for each new thread to avoid a series of identical
|
||||
* curl_easy_setopt() invokes in every thread.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ void Curl_amiga_cleanup(void)
|
|||
* Because we need to handle the different cases in hostip4.c at runtime,
|
||||
* not at compile-time, based on what was detected in Curl_amiga_init(),
|
||||
* we replace it completely with our own as to not complicate the baseline
|
||||
* code. Assumes malloc/calloc/free are thread safe because Curl_he2ai()
|
||||
* code. Assumes malloc/calloc/free are thread-safe because Curl_he2ai()
|
||||
* allocates memory also.
|
||||
*/
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname, int port)
|
|||
}
|
||||
else {
|
||||
#ifdef CURLRES_THREADED
|
||||
/* gethostbyname() is not thread safe, so we need to reopen bsdsocket
|
||||
/* gethostbyname() is not thread-safe, so we need to reopen bsdsocket
|
||||
* on the thread's context
|
||||
*/
|
||||
struct Library *base = OpenLibrary("bsdsocket.library", 4);
|
||||
|
|
|
|||
|
|
@ -38,9 +38,9 @@
|
|||
/* OS400 supports a 3-argument ASCII version of gethostbyaddr_r(), but its
|
||||
* prototype is incompatible with the "standard" one (1st argument is not
|
||||
* const). However, getaddrinfo() is supported (ASCII version defined as
|
||||
* a local wrapper in setup-os400.h) in a threadsafe way: we can then
|
||||
* a local wrapper in setup-os400.h) in a thread-safe way: we can then
|
||||
* configure getaddrinfo() as such and get rid of gethostbyname_r() without
|
||||
* loss of threadsafeness. */
|
||||
* loss of thread-safeness. */
|
||||
#undef HAVE_GETHOSTBYNAME_R
|
||||
#undef HAVE_GETHOSTBYNAME_R_3
|
||||
#undef HAVE_GETHOSTBYNAME_R_5
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ void Curl_dnscache_prune(struct Curl_easy *data);
|
|||
/* clear the DNS cache */
|
||||
void Curl_dnscache_clear(struct Curl_easy *data);
|
||||
|
||||
/* IPv4 threadsafe resolve function used for synch and asynch builds */
|
||||
/* IPv4 thread-safe resolve function used for synch and asynch builds */
|
||||
struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname, int port);
|
||||
|
||||
CURLcode Curl_once_resolved(struct Curl_easy *data,
|
||||
|
|
|
|||
|
|
@ -93,10 +93,10 @@ struct Curl_addrinfo *Curl_sync_getaddrinfo(struct Curl_easy *data,
|
|||
#if defined(CURLRES_IPV4) && !defined(CURLRES_ARES) && !defined(CURLRES_AMIGA)
|
||||
|
||||
/*
|
||||
* Curl_ipv4_resolve_r() - ipv4 threadsafe resolver function.
|
||||
* Curl_ipv4_resolve_r() - ipv4 thread-safe resolver function.
|
||||
*
|
||||
* This is used for both synchronous and asynchronous resolver builds,
|
||||
* implying that only threadsafe code and function calls may be used.
|
||||
* implying that only thread-safe code and function calls may be used.
|
||||
*
|
||||
*/
|
||||
struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
|
||||
|
|
@ -153,7 +153,7 @@ struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
|
|||
&h_errnop);
|
||||
|
||||
/* If the buffer is too small, it returns NULL and sets errno to
|
||||
* ERANGE. The errno is thread safe if this is compiled with
|
||||
* ERANGE. The errno is thread-safe if this is compiled with
|
||||
* -D_REENTRANT as then the 'errno' variable is a macro defined to get
|
||||
* used properly for threads.
|
||||
*/
|
||||
|
|
@ -263,7 +263,7 @@ struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
|
|||
#else /* (HAVE_GETADDRINFO && HAVE_GETADDRINFO_THREADSAFE) ||
|
||||
HAVE_GETHOSTBYNAME_R */
|
||||
/*
|
||||
* Here is code for platforms that do not have a thread safe
|
||||
* Here is code for platforms that do not have a thread-safe
|
||||
* getaddrinfo() nor gethostbyname_r() function or for which
|
||||
* gethostbyname() is the preferred one.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ CURLcode Curl_output_ntlm(struct Curl_easy *data, bool proxy)
|
|||
|
||||
#ifdef USE_WINDOWS_SSPI
|
||||
if(!Curl_pSecFn) {
|
||||
/* not thread safe and leaks - use curl_global_init() to avoid */
|
||||
/* not thread-safe and leaks - use curl_global_init() to avoid */
|
||||
CURLcode err = Curl_sspi_global_init();
|
||||
if(!Curl_pSecFn)
|
||||
return err;
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ struct memdebug {
|
|||
* For advanced analysis, record a log file and write perl scripts to analyze
|
||||
* them!
|
||||
*
|
||||
* Do not use these with multithreaded test programs!
|
||||
* Do not use these with multi-threaded test programs!
|
||||
*/
|
||||
|
||||
FILE *curl_dbg_logfile = NULL;
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ static ssize_t gtls_pull(void *s, void *buf, size_t blen)
|
|||
* gtls_init()
|
||||
*
|
||||
* Global GnuTLS init, called from Curl_ssl_init(). This calls functions that
|
||||
* are not thread-safe (It is thread safe since GnuTLS 3.3.0) and thus this
|
||||
* are not thread-safe (It is thread-safe since GnuTLS 3.3.0) and thus this
|
||||
* function itself is not thread-safe and must only be called from within
|
||||
* curl_global_init() to keep the thread situation under control!
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1265,7 +1265,7 @@ dnl true, and usage has not been previously disallowed
|
|||
dnl with shell variable curl_disallow_getaddrinfo, then
|
||||
dnl HAVE_GETADDRINFO will be defined. Additionally when
|
||||
dnl HAVE_GETADDRINFO gets defined this will also attempt
|
||||
dnl to find out if getaddrinfo happens to be threadsafe,
|
||||
dnl to find out if getaddrinfo happens to be thread-safe,
|
||||
dnl defining HAVE_GETADDRINFO_THREADSAFE when true.
|
||||
|
||||
AC_DEFUN([CURL_CHECK_FUNC_GETADDRINFO], [
|
||||
|
|
@ -1414,7 +1414,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETADDRINFO], [
|
|||
fi
|
||||
#
|
||||
if test "$curl_cv_func_getaddrinfo" = "yes"; then
|
||||
AC_MSG_CHECKING([if getaddrinfo is threadsafe])
|
||||
AC_MSG_CHECKING([if getaddrinfo is thread-safe])
|
||||
if test "$curl_cv_apple" = "yes"; then
|
||||
dnl Darwin 6.0 and macOS 10.2.X and newer
|
||||
tst_tsafe_getaddrinfo="yes"
|
||||
|
|
@ -1479,7 +1479,7 @@ AC_DEFUN([CURL_CHECK_FUNC_GETADDRINFO], [
|
|||
AC_MSG_RESULT([$tst_tsafe_getaddrinfo])
|
||||
if test "$tst_tsafe_getaddrinfo" = "yes"; then
|
||||
AC_DEFINE_UNQUOTED(HAVE_GETADDRINFO_THREADSAFE, 1,
|
||||
[Define to 1 if the getaddrinfo function is threadsafe.])
|
||||
[Define to 1 if the getaddrinfo function is thread-safe.])
|
||||
curl_cv_func_getaddrinfo_threadsafe="yes"
|
||||
else
|
||||
curl_cv_func_getaddrinfo_threadsafe="no"
|
||||
|
|
|
|||
|
|
@ -407,7 +407,7 @@ static void exit_signal_handler(int signum)
|
|||
* SIGINT is not supported for any Win32 application. When a CTRL+C
|
||||
* interrupt occurs, Win32 operating systems generate a new thread
|
||||
* to specifically handle that interrupt. This can cause a single-thread
|
||||
* application, such as one in UNIX, to become multithreaded and cause
|
||||
* application, such as one in UNIX, to become multi-threaded and cause
|
||||
* unexpected behavior.
|
||||
* [...]
|
||||
* The SIGKILL and SIGTERM signals are not generated under Windows.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue