]> git.ipfire.org Git - thirdparty/curl.git/commit
dllmain: Call OpenSSL thread cleanup for Windows and Cygwin
authorJay Satiro <raysatiro@yahoo.com>
Tue, 28 Nov 2023 08:39:09 +0000 (03:39 -0500)
committerJay Satiro <raysatiro@yahoo.com>
Wed, 24 Apr 2024 08:04:25 +0000 (04:04 -0400)
commit7860f575fe9e527ced66b31ec076914bbadd64a4
tree10bb4229df13294e1f357d72cd0f6741f0a07da9
parent3b8db84c1b00e6bd054dca05a4cbdab51b524803
dllmain: Call OpenSSL thread cleanup for Windows and Cygwin

- Call OPENSSL_thread_stop on thread termination (DLL_THREAD_DETACH)
  to prevent a memory leak in case OpenSSL is linked statically.

- Warn in libcurl-thread.3 that if OpenSSL is linked statically then it
  may require thread cleanup.

OpenSSL may need per-thread cleanup to stop a memory leak. For Windows
and Cygwin if libcurl was built as a DLL then we can do that for the
user by calling OPENSSL_thread_stop on thread termination. However, if
libcurl was built statically then we do not have notification of thread
termination and cannot do that for the user.

Also, there are several other unusual cases where it may be necessary
for the user to call OPENSSL_thread_stop, so in the libcurl-thread
warning I added a link to the OpenSSL documentation.

Co-authored-by: Viktor Szakats
Reported-by: southernedge@users.noreply.github.com
Reported-by: zmcx16@users.noreply.github.com
Ref: https://www.openssl.org/docs/man3.0/man3/OPENSSL_thread_stop.html#NOTES

Fixes https://github.com/curl/curl/issues/12327
Closes https://github.com/curl/curl/pull/12408
docs/libcurl/curl_global_cleanup.md
docs/libcurl/libcurl-thread.md
lib/CMakeLists.txt
lib/Makefile.inc
lib/dllmain.c [new file with mode: 0644]