mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-08-01 10:06:59 +03:00
debugged and fixed initialization problems which were giving troubles on
* parser.c parserInternals.c threads.c: debugged and fixed initialization problems which were giving troubles on SMP boxes. Daniel
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
Sun Oct 14 05:55:01 EDT 2001 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* parser.c parserInternals.c threads.c: debugged and fixed
|
||||||
|
initialization problems which were giving troubles on SMP
|
||||||
|
boxes.
|
||||||
|
|
||||||
Sat Oct 13 16:17:13 CEST 2001 Daniel Veillard <daniel@veillard.com>
|
Sat Oct 13 16:17:13 CEST 2001 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* include/libxml/Makefile.am: missing globals.h
|
* include/libxml/Makefile.am: missing globals.h
|
||||||
|
2
parser.c
2
parser.c
@ -10188,7 +10188,9 @@ void
|
|||||||
xmlInitParser(void) {
|
xmlInitParser(void) {
|
||||||
if (xmlParserInitialized) return;
|
if (xmlParserInitialized) return;
|
||||||
|
|
||||||
|
initGenericErrorDefaultFunc(NULL);
|
||||||
xmlInitThreads();
|
xmlInitThreads();
|
||||||
|
xmlInitMemory();
|
||||||
initGenericErrorDefaultFunc(NULL);
|
initGenericErrorDefaultFunc(NULL);
|
||||||
xmlInitCharEncodingHandlers();
|
xmlInitCharEncodingHandlers();
|
||||||
xmlInitializePredefinedEntities();
|
xmlInitializePredefinedEntities();
|
||||||
|
@ -74,7 +74,7 @@ void
|
|||||||
xmlCheckVersion(int version) {
|
xmlCheckVersion(int version) {
|
||||||
int myversion = (int) LIBXML_VERSION;
|
int myversion = (int) LIBXML_VERSION;
|
||||||
|
|
||||||
xmlInitMemory();
|
xmlInitParser();
|
||||||
|
|
||||||
if ((myversion / 10000) != (version / 10000)) {
|
if ((myversion / 10000) != (version / 10000)) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
59
threads.c
59
threads.c
@ -31,6 +31,7 @@
|
|||||||
#include <note.h>
|
#include <note.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* #define DEBUG_THREADS */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO: this module still uses malloc/free and not xmlMalloc/xmlFree
|
* TODO: this module still uses malloc/free and not xmlMalloc/xmlFree
|
||||||
@ -70,10 +71,13 @@ struct _xmlRMutex {
|
|||||||
* - keylock protecting globalkey
|
* - keylock protecting globalkey
|
||||||
* - keyonce to mark initialization of globalkey
|
* - keyonce to mark initialization of globalkey
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static int initialized = 0;
|
||||||
#ifdef HAVE_PTHREAD_H
|
#ifdef HAVE_PTHREAD_H
|
||||||
static pthread_mutex_t keylock;
|
static pthread_mutex_t keylock = PTHREAD_MUTEX_INITIALIZER;
|
||||||
static pthread_key_t globalkey;
|
static pthread_key_t globalkey;
|
||||||
static int keyonce = 0;
|
static int keyonce = 0;
|
||||||
|
static pthread_t mainthread;
|
||||||
#endif
|
#endif
|
||||||
static xmlRMutexPtr xmlLibraryLock = NULL;
|
static xmlRMutexPtr xmlLibraryLock = NULL;
|
||||||
|
|
||||||
@ -313,8 +317,10 @@ xmlGetGlobalState(void)
|
|||||||
|
|
||||||
pthread_setspecific(globalkey, tsd);
|
pthread_setspecific(globalkey, tsd);
|
||||||
return (tsd);
|
return (tsd);
|
||||||
} else
|
}
|
||||||
return (globalval);
|
return (globalval);
|
||||||
|
#else
|
||||||
|
return(NULL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,6 +331,29 @@ xmlGetGlobalState(void)
|
|||||||
* *
|
* *
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlIsMainThread:
|
||||||
|
*
|
||||||
|
* xmlIsMainThread() check wether the current thread is the main thread.
|
||||||
|
*
|
||||||
|
* Returns 1 if the current thread is the main thread, 0 otherwise
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
xmlIsMainThread(void)
|
||||||
|
{
|
||||||
|
if (!initialized)
|
||||||
|
xmlInitThreads();
|
||||||
|
|
||||||
|
#ifdef DEBUG_THREADS
|
||||||
|
xmlGenericError(xmlGenericErrorContext, "xmlIsMainThread()\n");
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_PTHREAD_H
|
||||||
|
return(mainthread == pthread_self());
|
||||||
|
#else
|
||||||
|
return(1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlLockLibrary:
|
* xmlLockLibrary:
|
||||||
*
|
*
|
||||||
@ -334,6 +363,9 @@ xmlGetGlobalState(void)
|
|||||||
void
|
void
|
||||||
xmlLockLibrary(void)
|
xmlLockLibrary(void)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_THREADS
|
||||||
|
xmlGenericError(xmlGenericErrorContext, "xmlLockLibrary()\n");
|
||||||
|
#endif
|
||||||
xmlRMutexLock(xmlLibraryLock);
|
xmlRMutexLock(xmlLibraryLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,6 +378,9 @@ xmlLockLibrary(void)
|
|||||||
void
|
void
|
||||||
xmlUnlockLibrary(void)
|
xmlUnlockLibrary(void)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_THREADS
|
||||||
|
xmlGenericError(xmlGenericErrorContext, "xmlUnlockLibrary()\n");
|
||||||
|
#endif
|
||||||
xmlRMutexUnlock(xmlLibraryLock);
|
xmlRMutexUnlock(xmlLibraryLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,6 +393,18 @@ xmlUnlockLibrary(void)
|
|||||||
void
|
void
|
||||||
xmlInitThreads(void)
|
xmlInitThreads(void)
|
||||||
{
|
{
|
||||||
|
if (initialized != 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
#ifdef DEBUG_THREADS
|
||||||
|
xmlGenericError(xmlGenericErrorContext, "xmlInitThreads()\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_PTHREAD_H
|
||||||
|
mainthread = pthread_self();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
initialized = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -369,4 +416,12 @@ xmlInitThreads(void)
|
|||||||
void
|
void
|
||||||
xmlCleanupThreads(void)
|
xmlCleanupThreads(void)
|
||||||
{
|
{
|
||||||
|
if (initialized == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
#ifdef DEBUG_THREADS
|
||||||
|
xmlGenericError(xmlGenericErrorContext, "xmlCleanupThreads()\n");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
initialized = 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user