ReactOS 0.4.16-dev-2232-gc2aaa52
threads.c File Reference
#include "libxml.h"
#include <string.h>
#include <stdlib.h>
#include <libxml/threads.h>
#include <libxml/parser.h>
#include "private/dict.h"
#include "private/enc.h"
#include "private/globals.h"
#include "private/memory.h"
#include "private/threads.h"
#include "private/xpath.h"
Include dependency graph for threads.c:

Go to the source code of this file.

Classes

struct  _xmlRMutex
 

Macros

#define IN_LIBXML
 
#define XML_IS_THREADED()   1
 
#define XML_IS_NEVER_THREADED()   0
 

Functions

void xmlInitMutex (xmlMutexPtr mutex)
 
xmlMutexPtr xmlNewMutex (void)
 
void xmlCleanupMutex (xmlMutexPtr mutex)
 
void xmlFreeMutex (xmlMutexPtr tok)
 
void xmlMutexLock (xmlMutexPtr tok)
 
void xmlMutexUnlock (xmlMutexPtr tok)
 
xmlRMutexPtr xmlNewRMutex (void)
 
void xmlFreeRMutex (xmlRMutexPtr tok ATTRIBUTE_UNUSED)
 
void xmlRMutexLock (xmlRMutexPtr tok)
 
void xmlRMutexUnlock (xmlRMutexPtr tok ATTRIBUTE_UNUSED)
 
int xmlGetThreadId (void)
 
void xmlLockLibrary (void)
 
void xmlUnlockLibrary (void)
 
void xmlInitThreads (void)
 
void xmlCleanupThreads (void)
 
static void xmlGlobalInitMutexLock (void)
 
static void xmlGlobalInitMutexUnlock (void)
 
static void xmlGlobalInitMutexDestroy (void)
 
void xmlInitParser (void)
 
void xmlCleanupParser (void)
 

Variables

static xmlRMutexPtr xmlLibraryLock = NULL
 
static int xmlParserInitialized = 0
 
static int xmlParserInnerInitialized = 0
 

Macro Definition Documentation

◆ IN_LIBXML

#define IN_LIBXML

threads.c: set of generic threading related routines

See Copyright for the status of this software.

Gary Pennington Gary..nosp@m.Penn.nosp@m.ingto.nosp@m.n@uk.nosp@m..sun..nosp@m.com danie.nosp@m.l@ve.nosp@m.illar.nosp@m.d.co.nosp@m.m

Definition at line 10 of file threads.c.

◆ XML_IS_NEVER_THREADED

#define XML_IS_NEVER_THREADED ( )    0

Definition at line 92 of file threads.c.

◆ XML_IS_THREADED

#define XML_IS_THREADED ( )    1

Definition at line 91 of file threads.c.

Function Documentation

◆ xmlCleanupMutex()

void xmlCleanupMutex ( xmlMutexPtr  mutex)

xmlCleanupMutex: @mutex: the simple mutex

Reclaim resources associated with a mutex.

Definition at line 166 of file threads.c.

167{
168#ifdef HAVE_POSIX_THREADS
169 if (XML_IS_NEVER_THREADED() == 0)
170 pthread_mutex_destroy(&mutex->lock);
171#elif defined HAVE_WIN32_THREADS
173#else
174 (void) mutex;
175#endif
176}
Definition: module.h:456
FAST_MUTEX lock
Definition: module.h:457
#define XML_IS_NEVER_THREADED()
Definition: threads.c:92
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)

Referenced by xmlCleanupDictInternal(), xmlCleanupGlobalsInternal(), xmlCleanupMemoryInternal(), xmlCleanupRandom(), and xmlFreeMutex().

◆ xmlCleanupParser()

void xmlCleanupParser ( void  )

xmlCleanupParser:

This function name is somewhat misleading. It does not clean up parser state, it cleans up memory allocated by the library itself. It is a cleanup function for the XML library. It tries to reclaim all related global memory allocated for the library processing. It doesn't deallocate any document related memory. One should call xmlCleanupParser() only when the process has finished using the library and all XML/HTML documents built with it. See also xmlInitParser() which has the opposite function of preparing the library for operations.

WARNING: if your application is multithreaded or has plugin support calling this may crash the application if another thread or a plugin is still using libxml2. It's sometimes very hard to guess if libxml2 is in use in the application, some libraries or plugins may use it without notice. In case of doubt abstain from calling this function or do it just before calling exit() to avoid leak reports from valgrind !

Definition at line 630 of file threads.c.

630 {
632 return;
633
634 /* These functions can call xmlFree. */
635
637#ifdef LIBXML_CATALOG_ENABLED
638 xmlCatalogCleanup();
639#endif
640#ifdef LIBXML_SCHEMAS_ENABLED
641 xmlSchemaCleanupTypes();
642 xmlRelaxNGCleanupTypes();
643#endif
644
645 /* These functions should never call xmlFree. */
646
648#ifdef LIBXML_OUTPUT_ENABLED
649 xmlCleanupOutputCallbacks();
650#endif
651
655 /*
656 * Must come last. On Windows, xmlCleanupGlobalsInternal can call
657 * xmlFree which uses xmlMemMutex in debug mode.
658 */
660
662
665}
void xmlCleanupCharEncodingHandlers(void)
Definition: encoding.c:1490
void xmlCleanupDictInternal(void)
Definition: dict.c:121
void xmlCleanupRandom(void)
Definition: dict.c:932
void xmlCleanupGlobalsInternal(void)
Definition: globals.c:617
XML_HIDDEN void xmlCleanupMemoryInternal(void)
Definition: xmlmemory.c:880
static int xmlParserInitialized
Definition: threads.c:445
static void xmlGlobalInitMutexDestroy(void)
Definition: threads.c:549
static int xmlParserInnerInitialized
Definition: threads.c:446
XML_GLOBALS_IO XMLPUBFUN void xmlCleanupInputCallbacks(void)

Referenced by DllMain(), and xmlInitParser().

◆ xmlCleanupThreads()

void xmlCleanupThreads ( void  )

xmlCleanupThreads:

DEPRECATED: This function is a no-op. Call xmlCleanupParser to free global state but see the warnings there. xmlCleanupParser should be only called once at program exit. In most cases, you don't have call cleanup functions at all.

Definition at line 435 of file threads.c.

436{
437}

◆ xmlFreeMutex()

void xmlFreeMutex ( xmlMutexPtr  tok)

xmlFreeMutex: @tok: the simple mutex

Free a mutex.

Definition at line 185 of file threads.c.

186{
187 if (tok == NULL)
188 return;
189
190 xmlCleanupMutex(tok);
191 free(tok);
192}
#define free
Definition: debug_ros.c:5
#define NULL
Definition: types.h:112
void xmlCleanupMutex(xmlMutexPtr mutex)
Definition: threads.c:166

Referenced by xsltCleanupGlobals().

◆ xmlFreeRMutex()

void xmlFreeRMutex ( xmlRMutexPtr tok  ATTRIBUTE_UNUSED)

xmlFreeRMutex: @tok: the reentrant mutex

xmlRFreeMutex() is used to reclaim resources associated with a reentrant mutex.

Definition at line 275 of file threads.c.

276{
277 if (tok == NULL)
278 return;
279#ifdef HAVE_POSIX_THREADS
280 if (XML_IS_NEVER_THREADED() == 0) {
281 pthread_mutex_destroy(&tok->lock);
282 pthread_cond_destroy(&tok->cv);
283 }
284#elif defined HAVE_WIN32_THREADS
285 DeleteCriticalSection(&tok->cs);
286#endif
287 free(tok);
288}

Referenced by xsltUninit().

◆ xmlGetThreadId()

int xmlGetThreadId ( void  )

xmlGetThreadId:

DEPRECATED: Internal function, do not use.

xmlGetThreadId() find the current thread ID number Note that this is likely to be broken on some platforms using pthreads as the specification doesn't mandate pthread_t to be an integer type

Returns the current thread ID number

Definition at line 372 of file threads.c.

373{
374#ifdef HAVE_POSIX_THREADS
375 pthread_t id;
376 int ret;
377
378 if (XML_IS_THREADED() == 0)
379 return (0);
380 id = pthread_self();
381 /* horrible but preserves compat, see warning above */
382 memcpy(&ret, &id, sizeof(ret));
383 return (ret);
384#elif defined HAVE_WIN32_THREADS
385 return GetCurrentThreadId();
386#else
387 return ((int) 0);
388#endif
389}
return ret
Definition: mutex.c:146
GLuint id
Definition: glext.h:5910
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define XML_IS_THREADED()
Definition: threads.c:91
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459

◆ xmlGlobalInitMutexDestroy()

static void xmlGlobalInitMutexDestroy ( void  )
static

xmlGlobalInitMutexDestroy

Makes sure that the global initialization mutex is destroyed before application termination.

Definition at line 549 of file threads.c.

549 {
550#ifdef HAVE_POSIX_THREADS
551#elif defined HAVE_WIN32_THREADS
552 if (global_init_lock != NULL) {
553 DeleteCriticalSection(global_init_lock);
554 free(global_init_lock);
555 global_init_lock = NULL;
556 }
557#endif
558}

Referenced by xmlCleanupParser().

◆ xmlGlobalInitMutexLock()

static void xmlGlobalInitMutexLock ( void  )
static

xmlGlobalInitMutexLock

Makes sure that the global initialization mutex is initialized and locks it.

Definition at line 462 of file threads.c.

462 {
463#ifdef HAVE_POSIX_THREADS
464
465#ifdef XML_PTHREAD_WEAK
466 /*
467 * This is somewhat unreliable since libpthread could be loaded
468 * later with dlopen() and threads could be created. But it's
469 * long-standing behavior and hard to work around.
470 */
471 if (libxml_is_threaded == -1)
472 libxml_is_threaded =
473 (pthread_mutex_init != NULL) &&
474 (pthread_mutex_destroy != NULL) &&
475 (pthread_mutex_lock != NULL) &&
476 (pthread_mutex_unlock != NULL) &&
477 (pthread_cond_init != NULL) &&
478 (pthread_cond_destroy != NULL) &&
479 (pthread_cond_wait != NULL) &&
480 /*
481 * pthread_equal can be inline, resuting in -Waddress warnings.
482 * Let's assume it's available if all the other functions are.
483 */
484 /* (pthread_equal != NULL) && */
485 (pthread_self != NULL) &&
486 (pthread_cond_signal != NULL);
487#endif
488
489 /* The mutex is statically initialized, so we just lock it. */
490 if (XML_IS_THREADED() != 0)
491 pthread_mutex_lock(&global_init_lock);
492
493#elif defined HAVE_WIN32_THREADS
494
496
497 /* Create a new critical section */
498 if (global_init_lock == NULL) {
499 cs = malloc(sizeof(CRITICAL_SECTION));
500 if (cs == NULL) {
502 "xmlGlobalInitMutexLock: out of memory\n");
503 return;
504 }
506
507 /* Swap it into the global_init_lock */
508#ifdef InterlockedCompareExchangePointer
509 InterlockedCompareExchangePointer((void **) &global_init_lock,
510 cs, NULL);
511#else /* Use older void* version */
512 InterlockedCompareExchange((void **) &global_init_lock,
513 (void *) cs, NULL);
514#endif /* InterlockedCompareExchangePointer */
515
516 /* If another thread successfully recorded its critical
517 * section in the global_init_lock then discard the one
518 * allocated by this thread. */
519 if (global_init_lock != cs) {
521 free(cs);
522 }
523 }
524
525 /* Lock the chosen critical section */
526 EnterCriticalSection(global_init_lock);
527
528#endif
529}
#define malloc
Definition: debug_ros.c:4
#define cs
Definition: i386-dis.c:442
#define InterlockedCompareExchangePointer
Definition: interlocked.h:144
#define InterlockedCompareExchange
Definition: interlocked.h:119
void * xmlGenericErrorContext
Definition: globals.c:410
xmlGenericErrorFunc xmlGenericError
Definition: globals.c:396
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

Referenced by xmlInitParser().

◆ xmlGlobalInitMutexUnlock()

static void xmlGlobalInitMutexUnlock ( void  )
static

Definition at line 532 of file threads.c.

532 {
533#ifdef HAVE_POSIX_THREADS
534 if (XML_IS_THREADED() != 0)
535 pthread_mutex_unlock(&global_init_lock);
536#elif defined HAVE_WIN32_THREADS
537 if (global_init_lock != NULL)
538 LeaveCriticalSection(global_init_lock);
539#endif
540}
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by xmlInitParser().

◆ xmlInitMutex()

void xmlInitMutex ( xmlMutexPtr  mutex)

xmlInitMutex: @mutex: the mutex

Initialize a mutex.

Definition at line 128 of file threads.c.

129{
130#ifdef HAVE_POSIX_THREADS
131 if (XML_IS_NEVER_THREADED() == 0)
132 pthread_mutex_init(&mutex->lock, NULL);
133#elif defined HAVE_WIN32_THREADS
135#else
136 (void) mutex;
137#endif
138}

Referenced by xmlInitDictInternal(), xmlInitGlobalsInternal(), xmlInitMemoryInternal(), xmlInitRandom(), and xmlNewMutex().

◆ xmlInitParser()

void xmlInitParser ( void  )

xmlInitParser:

Initialization function for the XML parser.

Call once from the main thread before using the library in multithreaded programs.

Definition at line 569 of file threads.c.

569 {
570 /*
571 * Note that the initialization code must not make memory allocations.
572 */
573 if (xmlParserInitialized != 0)
574 return;
575
577
578 if (xmlParserInnerInitialized == 0) {
579#if defined(_WIN32) && \
580 !defined(LIBXML_THREAD_ALLOC_ENABLED) && \
581 (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
582 if (xmlFree == free)
584#endif
585
586 xmlInitMemoryInternal(); /* Should come second */
591#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
593#endif
594
596#ifdef LIBXML_OUTPUT_ENABLED
597 xmlRegisterDefaultOutputCallbacks();
598#endif /* LIBXML_OUTPUT_ENABLED */
599
601 }
602
604
606}
int __cdecl atexit(void(__cdecl *)(void))
Definition: atonexit.c:97
void xmlInitEncodingInternal(void)
Definition: encoding.c:1470
XML_HIDDEN void xmlInitXPathInternal(void)
ATTRIBUTE_NO_SANITIZE_INTEGER void xmlInitRandom(void)
Definition: dict.c:918
void xmlInitDictInternal(void)
Definition: dict.c:99
xmlFreeFunc xmlFree
Definition: globals.c:184
void xmlInitGlobalsInternal(void)
Definition: globals.c:571
XML_HIDDEN void xmlInitMemoryInternal(void)
Definition: xmlmemory.c:846
static void xmlGlobalInitMutexUnlock(void)
Definition: threads.c:532
void xmlCleanupParser(void)
Definition: threads.c:630
static void xmlGlobalInitMutexLock(void)
Definition: threads.c:462
XMLPUBFUN void xmlRegisterDefaultInputCallbacks(void)

Referenced by DllMain(), xmlCheckVersion(), xmlCtxtReadDoc(), xmlCtxtReadFd(), xmlCtxtReadFile(), xmlCtxtReadIO(), xmlCtxtReadMemory(), xmlDictCreate(), xmlHashCreate(), xmlInitCharEncodingHandlers(), xmlInitGlobals(), xmlInitializeDict(), xmlInitMemory(), xmlInitSAXParserCtxt(), xmlInitThreads(), xmlIsMainThreadInternal(), xmlMallocAtomicLoc(), xmlMallocLoc(), xmlMemStrdupLoc(), xmlParseDocument(), xmlReadDoc(), xmlReadFd(), xmlReadFile(), xmlReadIO(), xmlReadMemory(), and xmlReallocLoc().

◆ xmlInitThreads()

void xmlInitThreads ( void  )

xmlInitThreads:

DEPRECATED: Alias for xmlInitParser.

Definition at line 421 of file threads.c.

422{
424}
void xmlInitParser(void)
Definition: threads.c:569

◆ xmlLockLibrary()

void xmlLockLibrary ( void  )

xmlLockLibrary:

xmlLockLibrary() is used to take out a re-entrant lock on the libxml2 library.

Definition at line 398 of file threads.c.

399{
401}
static xmlRMutexPtr xmlLibraryLock
Definition: threads.c:119
void xmlRMutexLock(xmlRMutexPtr tok)
Definition: threads.c:297

◆ xmlMutexLock()

void xmlMutexLock ( xmlMutexPtr  tok)

xmlMutexLock: @tok: the simple mutex

xmlMutexLock() is used to lock a libxml2 token.

Definition at line 201 of file threads.c.

202{
203 if (tok == NULL)
204 return;
205#ifdef HAVE_POSIX_THREADS
206 /*
207 * This assumes that __libc_single_threaded won't change while the
208 * lock is held.
209 */
210 if (XML_IS_THREADED() != 0)
211 pthread_mutex_lock(&tok->lock);
212#elif defined HAVE_WIN32_THREADS
213 EnterCriticalSection(&tok->cs);
214#endif
215
216}

Referenced by xmlDictFree(), xmlDictReference(), xmlMallocAtomicLoc(), xmlMallocLoc(), xmlMemBlocks(), xmlMemDisplay(), xmlMemDisplayLast(), xmlMemFree(), xmlMemShow(), xmlMemStrdupLoc(), xmlRandom(), xmlReallocLoc(), xmlThrDefBufferAllocScheme(), xmlThrDefDefaultBufferSize(), xmlThrDefDeregisterNodeDefault(), xmlThrDefDoValidityCheckingDefaultValue(), xmlThrDefGetWarningsDefaultValue(), xmlThrDefKeepBlanksDefaultValue(), xmlThrDefLineNumbersDefaultValue(), xmlThrDefLoadExtDtdDefaultValue(), xmlThrDefOutputBufferCreateFilenameDefault(), xmlThrDefParserDebugEntities(), xmlThrDefParserInputBufferCreateFilenameDefault(), xmlThrDefPedanticParserDefaultValue(), xmlThrDefRegisterNodeDefault(), xmlThrDefSetGenericErrorFunc(), xmlThrDefSetStructuredErrorFunc(), xmlThrDefSubstituteEntitiesDefaultValue(), xsltCleanupGlobals(), xsltDebugDumpExtensions(), xsltExtModuleElementLookup(), xsltExtModuleElementPreComputeLookup(), xsltExtModuleFunctionLookup(), xsltExtModuleTopLevelLookup(), xsltGetExtData(), xsltPreComputeExtModuleElement(), xsltRegisterExtModuleElement(), xsltRegisterExtModuleFull(), xsltRegisterExtModuleFunction(), xsltRegisterExtModuleTopLevel(), xsltRegisterExtPrefix(), xsltStyleInitializeStylesheetModule(), xsltUnregisterAllExtModuleElement(), xsltUnregisterAllExtModuleFunction(), xsltUnregisterAllExtModules(), xsltUnregisterAllExtModuleTopLevel(), xsltUnregisterExtModule(), xsltUnregisterExtModuleElement(), xsltUnregisterExtModuleFunction(), and xsltUnregisterExtModuleTopLevel().

◆ xmlMutexUnlock()

void xmlMutexUnlock ( xmlMutexPtr  tok)

xmlMutexUnlock: @tok: the simple mutex

xmlMutexUnlock() is used to unlock a libxml2 token.

Definition at line 225 of file threads.c.

226{
227 if (tok == NULL)
228 return;
229#ifdef HAVE_POSIX_THREADS
230 if (XML_IS_THREADED() != 0)
231 pthread_mutex_unlock(&tok->lock);
232#elif defined HAVE_WIN32_THREADS
233 LeaveCriticalSection(&tok->cs);
234#endif
235}

Referenced by xmlDictFree(), xmlDictReference(), xmlMallocAtomicLoc(), xmlMallocLoc(), xmlMemBlocks(), xmlMemDisplay(), xmlMemDisplayLast(), xmlMemFree(), xmlMemShow(), xmlMemStrdupLoc(), xmlRandom(), xmlReallocLoc(), xmlThrDefBufferAllocScheme(), xmlThrDefDefaultBufferSize(), xmlThrDefDeregisterNodeDefault(), xmlThrDefDoValidityCheckingDefaultValue(), xmlThrDefGetWarningsDefaultValue(), xmlThrDefKeepBlanksDefaultValue(), xmlThrDefLineNumbersDefaultValue(), xmlThrDefLoadExtDtdDefaultValue(), xmlThrDefOutputBufferCreateFilenameDefault(), xmlThrDefParserDebugEntities(), xmlThrDefParserInputBufferCreateFilenameDefault(), xmlThrDefPedanticParserDefaultValue(), xmlThrDefRegisterNodeDefault(), xmlThrDefSetGenericErrorFunc(), xmlThrDefSetStructuredErrorFunc(), xmlThrDefSubstituteEntitiesDefaultValue(), xsltCleanupGlobals(), xsltDebugDumpExtensions(), xsltExtModuleElementLookup(), xsltExtModuleElementPreComputeLookup(), xsltExtModuleFunctionLookup(), xsltExtModuleTopLevelLookup(), xsltGetExtData(), xsltPreComputeExtModuleElement(), xsltRegisterExtModuleElement(), xsltRegisterExtModuleFull(), xsltRegisterExtModuleFunction(), xsltRegisterExtModuleTopLevel(), xsltRegisterExtPrefix(), xsltStyleInitializeStylesheetModule(), xsltUnregisterAllExtModuleElement(), xsltUnregisterAllExtModuleFunction(), xsltUnregisterAllExtModules(), xsltUnregisterAllExtModuleTopLevel(), xsltUnregisterExtModule(), xsltUnregisterExtModuleElement(), xsltUnregisterExtModuleFunction(), and xsltUnregisterExtModuleTopLevel().

◆ xmlNewMutex()

xmlMutexPtr xmlNewMutex ( void  )

xmlNewMutex:

xmlNewMutex() is used to allocate a libxml2 token struct for use in synchronizing access to data.

Returns a new simple mutex pointer or NULL in case of error

Definition at line 149 of file threads.c.

150{
151 xmlMutexPtr tok;
152
153 if ((tok = malloc(sizeof(xmlMutex))) == NULL)
154 return (NULL);
155 xmlInitMutex(tok);
156 return (tok);
157}
void xmlInitMutex(xmlMutexPtr mutex)
Definition: threads.c:128

Referenced by xsltInitGlobals().

◆ xmlNewRMutex()

xmlRMutexPtr xmlNewRMutex ( void  )

xmlNewRMutex:

xmlRNewMutex() is used to allocate a reentrant mutex for use in synchronizing access to data. token_r is a re-entrant lock and thus useful for synchronizing access to data structures that may be manipulated in a recursive fashion.

Returns the new reentrant mutex pointer or NULL in case of error

Definition at line 248 of file threads.c.

249{
250 xmlRMutexPtr tok;
251
252 if ((tok = malloc(sizeof(xmlRMutex))) == NULL)
253 return (NULL);
254#ifdef HAVE_POSIX_THREADS
255 if (XML_IS_NEVER_THREADED() == 0) {
256 pthread_mutex_init(&tok->lock, NULL);
257 tok->held = 0;
258 tok->waiters = 0;
259 pthread_cond_init(&tok->cv, NULL);
260 }
261#elif defined HAVE_WIN32_THREADS
263#endif
264 return (tok);
265}

Referenced by xsltInit().

◆ xmlRMutexLock()

void xmlRMutexLock ( xmlRMutexPtr  tok)

xmlRMutexLock: @tok: the reentrant mutex

xmlRMutexLock() is used to lock a libxml2 token_r.

Definition at line 297 of file threads.c.

298{
299 if (tok == NULL)
300 return;
301#ifdef HAVE_POSIX_THREADS
302 if (XML_IS_THREADED() == 0)
303 return;
304
305 pthread_mutex_lock(&tok->lock);
306 if (tok->held) {
307 if (pthread_equal(tok->tid, pthread_self())) {
308 tok->held++;
309 pthread_mutex_unlock(&tok->lock);
310 return;
311 } else {
312 tok->waiters++;
313 while (tok->held)
314 pthread_cond_wait(&tok->cv, &tok->lock);
315 tok->waiters--;
316 }
317 }
318 tok->tid = pthread_self();
319 tok->held = 1;
320 pthread_mutex_unlock(&tok->lock);
321#elif defined HAVE_WIN32_THREADS
322 EnterCriticalSection(&tok->cs);
323#endif
324}

Referenced by xmlLockLibrary(), and xsltFreeLocales().

◆ xmlRMutexUnlock()

void xmlRMutexUnlock ( xmlRMutexPtr tok  ATTRIBUTE_UNUSED)

xmlRMutexUnlock: @tok: the reentrant mutex

xmlRMutexUnlock() is used to unlock a libxml2 token_r.

Definition at line 333 of file threads.c.

334{
335 if (tok == NULL)
336 return;
337#ifdef HAVE_POSIX_THREADS
338 if (XML_IS_THREADED() == 0)
339 return;
340
341 pthread_mutex_lock(&tok->lock);
342 tok->held--;
343 if (tok->held == 0) {
344 if (tok->waiters)
345 pthread_cond_signal(&tok->cv);
346 memset(&tok->tid, 0, sizeof(tok->tid));
347 }
348 pthread_mutex_unlock(&tok->lock);
349#elif defined HAVE_WIN32_THREADS
350 LeaveCriticalSection(&tok->cs);
351#endif
352}
#define memset(x, y, z)
Definition: compat.h:39

Referenced by xmlUnlockLibrary(), and xsltFreeLocales().

◆ xmlUnlockLibrary()

void xmlUnlockLibrary ( void  )

xmlUnlockLibrary:

xmlUnlockLibrary() is used to release a re-entrant lock on the libxml2 library.

Definition at line 410 of file threads.c.

411{
413}
void xmlRMutexUnlock(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
Definition: threads.c:333

Variable Documentation

◆ xmlLibraryLock

xmlRMutexPtr xmlLibraryLock = NULL
static

Definition at line 119 of file threads.c.

Referenced by xmlLockLibrary(), and xmlUnlockLibrary().

◆ xmlParserInitialized

int xmlParserInitialized = 0
static

Definition at line 445 of file threads.c.

Referenced by xmlCleanupParser(), and xmlInitParser().

◆ xmlParserInnerInitialized

int xmlParserInnerInitialized = 0
static

Definition at line 446 of file threads.c.

Referenced by xmlCleanupParser(), and xmlInitParser().