Change #261873
| Category | curl |
| Changed by | Stefan Eissing <stefan@eissing.org> |
| Changed at | Sat 21 Mar 2026 14:42:49 |
| Repository | https://github.com/curl/curl.git |
| Project | curl |
| Branch | master |
| Revision | 82009c4220774417c821496affa4aa834c028b68 |
Comments
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
Changed files
- CMakeLists.txt
- configure.ac
- docs/libcurl/curl_share_cleanup.md
- lib/amigaos.c
- lib/asyn-ares.c
- lib/asyn-base.c
- lib/asyn-thrdd.c
- lib/asyn.h
- lib/config-win32.h
- lib/curl_config-cmake.h.in
- lib/curl_setup.h
- lib/curl_share.c
- lib/curl_share.h
- lib/curl_threads.c
- lib/curl_threads.h
- lib/easy_lock.h
- lib/hostip.c
- lib/hostip4.c
- lib/memdebug.c
- lib/setopt.c
- lib/url.c
- lib/version.c
- projects/vms/generate_config_vms_h_curl.com
- src/curlinfo.c
- tests/data/test506
- tests/libtest/lib3207.c