mirror of
https://github.com/curl/curl.git
synced 2026-04-14 18:31:42 +03:00
share: concurrency handling, easy updates
Replace the `volatile int dirty` with a reference counter protected by a mutex when available. Solve the problem of when to call application's lock function by adding a volatile flag that indicates a share has been added to easy handles in its lifetime. That flag ever goes from FALSE to TRUE, so volatile might work (in the absence of a mutex). (The problem is that the lock/unlock functions need 2-3 `curl_share_setopt()` invocations to become usable and there is no way of telling if the third will ever happen. Calling the lock function before the 3rd setopt may crash the application.) When removing a share from an easy handle (or replacing it with another share), detach the easy connection on a share with a connection pool. When cleaning up a share, allow this even if it is still used in easy handles. It will be destroyed when the reference count drops to 0. Closes #20870
This commit is contained in:
parent
745344ea4e
commit
82009c4220
26 changed files with 378 additions and 210 deletions
|
|
@ -630,15 +630,20 @@ if(DOS OR AMIGA)
|
|||
set(HAVE_TIME_T_UNSIGNED 1)
|
||||
endif()
|
||||
|
||||
if(NOT WIN32)
|
||||
find_package(Threads)
|
||||
set(HAVE_THREADS_POSIX ${CMAKE_USE_PTHREADS_INIT})
|
||||
set(HAVE_PTHREAD_H ${CMAKE_USE_PTHREADS_INIT})
|
||||
list(APPEND CURL_NETWORK_AND_TIME_LIBS ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif()
|
||||
|
||||
if(ENABLE_THREADED_RESOLVER)
|
||||
if(WIN32)
|
||||
set(USE_THREADS_WIN32 ON)
|
||||
else()
|
||||
find_package(Threads REQUIRED)
|
||||
set(USE_THREADS_POSIX ${CMAKE_USE_PTHREADS_INIT})
|
||||
set(HAVE_PTHREAD_H ${CMAKE_USE_PTHREADS_INIT})
|
||||
list(APPEND CURL_NETWORK_AND_TIME_LIBS ${CMAKE_THREAD_LIBS_INIT})
|
||||
if(NOT WIN32 AND NOT HAVE_THREADS_POSIX)
|
||||
message(FATAL_ERROR "Threaded resolver requires POSIX Threads.")
|
||||
endif()
|
||||
set(USE_RESOLV_THREADED ON)
|
||||
elseif(USE_ARES)
|
||||
set(USE_RESOLV_ARES ON)
|
||||
endif()
|
||||
|
||||
# Check for all needed libraries
|
||||
|
|
@ -1998,8 +2003,8 @@ curl_add_if("libz" HAVE_LIBZ)
|
|||
curl_add_if("brotli" HAVE_BROTLI)
|
||||
curl_add_if("gsasl" USE_GSASL)
|
||||
curl_add_if("zstd" HAVE_ZSTD)
|
||||
curl_add_if("AsynchDNS" USE_ARES OR USE_THREADS_POSIX OR USE_THREADS_WIN32)
|
||||
curl_add_if("asyn-rr" USE_ARES AND ENABLE_THREADED_RESOLVER AND USE_HTTPSRR)
|
||||
curl_add_if("AsynchDNS" USE_RESOLV_ARES OR USE_RESOLV_THREADED)
|
||||
curl_add_if("asyn-rr" USE_ARES AND USE_RESOLV_THREADED AND USE_HTTPSRR)
|
||||
curl_add_if("IDN" (HAVE_LIBIDN2 AND HAVE_IDN2_H) OR
|
||||
USE_WIN32_IDN OR
|
||||
USE_APPLE_IDN)
|
||||
|
|
@ -2022,7 +2027,7 @@ curl_add_if("HTTPS-proxy" NOT CURL_DISABLE_PROXY AND _ssl_enabled AND (USE_OPE
|
|||
OR USE_SCHANNEL OR USE_RUSTLS OR USE_MBEDTLS OR
|
||||
(USE_WOLFSSL AND HAVE_WOLFSSL_BIO_NEW)))
|
||||
curl_add_if("Unicode" ENABLE_UNICODE)
|
||||
curl_add_if("threadsafe" HAVE_ATOMIC OR (USE_THREADS_POSIX AND HAVE_PTHREAD_H) OR WIN32)
|
||||
curl_add_if("threadsafe" HAVE_ATOMIC OR (HAVE_THREADS_POSIX AND HAVE_PTHREAD_H) OR WIN32)
|
||||
curl_add_if("Debug" ENABLE_DEBUG)
|
||||
curl_add_if("ECH" _ssl_enabled AND HAVE_ECH)
|
||||
curl_add_if("HTTPSRR" _ssl_enabled AND USE_HTTPSRR)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue