Hi!

If I use the library in a threaded program and call xmlCleanupParser() I can't reinitialize it.

So here's what happens:

1. xmlCleanupThreads() is called from xmlCleanupParser()
2. the global key is deleted by xmlCleanupParser() which was created by xmlOnceInit()

So the problem is that if I want to clear the data allocated then I can't use the library because it will leak memory (xmlOnceInit will not be called). The simplest way to solve this issue is to reset once_control.

The other way is to remove xmlCleanupThreads() from the cleanup process and let the user/programmer do the dirty work...

Aron Szabo
Pointless Software
diff --git a/threads.c b/threads.c
index 98fd2c2..7f421dd 100644
--- a/threads.c
+++ b/threads.c
@@ -911,8 +911,10 @@ xmlCleanupThreads(void)
     xmlGenericError(xmlGenericErrorContext, "xmlCleanupThreads()\n");
 #endif
 #ifdef HAVE_PTHREAD_H
-    if ((libxml_is_threaded)  && (pthread_key_delete != NULL))
+    if ((libxml_is_threaded)  && (pthread_key_delete != NULL)) {
         pthread_key_delete(globalkey);
+       once_control = PTHREAD_ONCE_INIT;
+    }
 #elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && 
(!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
     if (globalkey != TLS_OUT_OF_INDEXES) {
         xmlGlobalStateCleanupHelperParams *p;
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml

Reply via email to