[libxml2] Fix xmlCleanupThreads on Windows



commit d70e548fe761b8ac4f6c8830f9052cfc0c289a00
Author: Nick Wellnhofer <wellnhofer aevum de>
Date:   Wed Jun 15 17:25:03 2022 +0200

    Fix xmlCleanupThreads on Windows
    
    Fix #ifdef logic:
    
    - Also free TLS key in static build.
    - Always reset 'run_once' state.

 threads.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/threads.c b/threads.c
index ca43c96a..f462ebf2 100644
--- a/threads.c
+++ b/threads.c
@@ -906,8 +906,10 @@ xmlCleanupThreads(void)
     if (libxml_is_threaded != 0)
         pthread_key_delete(globalkey);
     once_control = once_control_init;
-#elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || 
defined(LIBXML_STATIC_FOR_DLL))
+#elif defined(HAVE_WIN32_THREADS)
+#if !defined(HAVE_COMPILER_TLS)
     if (globalkey != TLS_OUT_OF_INDEXES) {
+#if !defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL)
         xmlGlobalStateCleanupHelperParams *p;
 
         EnterCriticalSection(&cleanup_helpers_cs);
@@ -921,10 +923,14 @@ xmlCleanupThreads(void)
         }
         cleanup_helpers_head = 0;
         LeaveCriticalSection(&cleanup_helpers_cs);
+#endif
         TlsFree(globalkey);
         globalkey = TLS_OUT_OF_INDEXES;
     }
+#if !defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL)
     DeleteCriticalSection(&cleanup_helpers_cs);
+#endif
+#endif
     run_once.done = 0;
     run_once.control = 0;
 #endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]