Commit fde5b0b9 authored by Daniel Veillard's avatar Daniel Veillard

small cleanup to avoid packaging .svn applied patch to avoid a problem in

* Makefile.am: small cleanup to avoid packaging .svn
* libxml.h threads.c parser.c: applied patch to avoid a problem
  in concurrent threaded initialization fix from Ted Phelps
Daniel

svn path=/trunk/; revision=3582
parent bf9a73d2
Mon Feb 12 18:30:01 CET 2007 Daniel Veillard <daniel@veillard.com>
* Makefile.am: small cleanup to avoid packaging .svn
* libxml.h threads.c parser.c: applied patch to avoid a problem
in concurrent threaded initialization fix from Ted Phelps
Thu Feb 08 15:35:18 PST 2007 William Brack <wbrack@mmm.com.hk>
* parser.c: added a GROW when parsing complex comments (bug #405666)
......
......@@ -1108,14 +1108,14 @@ cleanup:
dist-hook: cleanup libxml2.spec
-cp libxml2.spec $(distdir)
(cd $(srcdir) ; tar -cf - --exclude CVS win32 macos vms bakefile test result) | (cd $(distdir); tar xf -)
(cd $(srcdir) ; tar -cf - --exclude CVS --exclude .svn win32 macos vms bakefile test result) | (cd $(distdir); tar xf -)
dist-source: distdir
$(AMTAR) -chof - --exclude Tests --exclude test --exclude result $(distdir) | GZIP=$(GZIP_ENV) gzip -c >`echo "$(distdir)" | sed "s+libxml2+libxml2-sources+"`.tar.gz
dist-test: distdir
(mkdir -p $(distdir))
(cd $(srcdir) ; tar -cf - --exclude CVS xstc/Tests) | (cd $(distdir); tar xf -)
(cd $(srcdir) ; tar -cf - --exclude CVS --exclude .svn xstc/Tests) | (cd $(distdir); tar xf -)
tar -cf - $(distdir)/test $(distdir)/result $(distdir)/xstc/Tests $(distdir)/Makefile.tests $(distdir)/README $(distdir)/README.tests $(distdir)/AUTHORS $(distdir)/testapi.c $(distdir)/runtest.c $(distdir)/runsuite.c | GZIP=$(GZIP_ENV) gzip -c >`echo "$(distdir)" | sed "s+libxml2+libxml2-tests+"`.tar.gz
@(rm -rf $(distdir)/xstc/Test)
......
......@@ -576,7 +576,7 @@ void <a href="#xmlParseEntityDecl">xmlParseEntityDecl</a> (<a href="libxml2-tre
<hr/>
<div class="refsect2" lang="en"><h3><a name="xmlParseSDDecl"/>xmlParseSDDecl ()</h3><pre class="programlisting">int xmlParseSDDecl (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br/>
</pre><p>parse the XML standalone declaration [32] SDDecl ::= S 'standalone' Eq (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no')'"')) [ VC: Standalone Document Declaration ] TODO The standalone document declaration must have the value "no" if any external markup declarations contain declarations of: - attributes with default values, if elements to which these attributes apply appear in the document without specifications of values for these attributes, or - entities (other than amp, lt, gt, apos, quot), if references to those entities appear in the document, or - attributes with values subject to normalization, where the <a href="libxml2-SAX.html#attribute">attribute</a> appears in the document with a value which will change as a result of normalization, or - element types with element content, if white space occurs directly within any instance of those types.</p>
<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>an XML parser context</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>1 if standalone, 0 otherwise</td></tr></tbody></table></div></div>
<div class="variablelist"><table border="0"><col align="left"/><tbody><tr><td><span class="term"><i><tt>ctxt</tt></i>:</span></td><td>an XML parser context</td></tr><tr><td><span class="term"><i><tt>Returns</tt></i>:</span></td><td>1 if standalone="yes" 0 if standalone="no" -2 if standalone <a href="libxml2-SAX.html#attribute">attribute</a> is missing or invalid (A standalone value of -2 means that the XML declaration was found, but no value was specified for the standalone attribute).</td></tr></tbody></table></div></div>
<hr/>
<div class="refsect2" lang="en"><h3><a name="xmlParseStartTag"/>xmlParseStartTag ()</h3><pre class="programlisting">const <a href="libxml2-xmlstring.html#xmlChar">xmlChar</a> * xmlParseStartTag (<a href="libxml2-tree.html#xmlParserCtxtPtr">xmlParserCtxtPtr</a> ctxt)<br/>
</pre><p>parse a start of tag either for rule element or EmptyElement. In both case we don't parse the tag closing chars. [40] STag ::= '&lt;' Name (S Attribute)* S? '&gt;' [ WFC: Unique Att Spec ] No <a href="libxml2-SAX.html#attribute">attribute</a> name may appear more than once in the same start-tag or empty-element tag. [44] EmptyElemTag ::= '&lt;' Name (S Attribute)* S? '/&gt;' [ WFC: Unique Att Spec ] No <a href="libxml2-SAX.html#attribute">attribute</a> name may appear more than once in the same start-tag or empty-element tag. With namespace: [NS 8] STag ::= '&lt;' QName (S Attribute)* S? '&gt;' [NS 10] EmptyElement ::= '&lt;' QName (S Attribute)* S? '/&gt;'</p>
......
......@@ -409,7 +409,7 @@ void <a href="#xmlFreeNsList">xmlFreeNsList</a> (<a href="libxml2-tree.html#xm
struct _xmlNode * prev : previous sibling link
struct _xmlDoc * doc : autoreference to itself End of common part
int compression : level of zlib compression
int standalone : standalone document (no external refs)
int standalone : standalone document (no external refs) 1 if standalone="yes" 0 if sta
struct _xmlDtd * intSubset : the document internal subset
struct _xmlDtd * extSubset : the document external subset
struct _xmlNs * oldNs : Global namespace, the old way
......
This diff is collapsed.
......@@ -2990,6 +2990,7 @@
<function name="xmlTextReaderSetParserProp ()" link="libxml2-xmlreader.html#xmlTextReaderSetParserProp"/>
<function name="xmlTextReaderSetSchema ()" link="libxml2-xmlreader.html#xmlTextReaderSetSchema"/>
<function name="xmlTextReaderSetStructuredErrorHandler ()" link="libxml2-xmlreader.html#xmlTextReaderSetStructuredErrorHandler"/>
<function name="xmlTextReaderSetup ()" link="libxml2-xmlreader.html#xmlTextReaderSetup"/>
<function name="xmlTextReaderStandalone ()" link="libxml2-xmlreader.html#xmlTextReaderStandalone"/>
<function name="xmlTextReaderValue ()" link="libxml2-xmlreader.html#xmlTextReaderValue"/>
<function name="xmlTextReaderXmlLang ()" link="libxml2-xmlreader.html#xmlTextReaderXmlLang"/>
......
......@@ -64,6 +64,11 @@ void __xmlLoaderErr(void *ctx, const char *msg, const char *filename);
void __htmlParseContent(void *ctx);
#endif
/*
* internal global initialization critical section routines.
*/
void __xmlGlobalInitMutexLock(void);
void __xmlGlobalInitMutexUnlock(void);
#ifdef IN_LIBXML
#ifdef __GNUC__
......
......@@ -12845,26 +12845,34 @@ xmlInitParser(void) {
if (xmlParserInitialized != 0)
return;
if ((xmlGenericError == xmlGenericErrorDefaultFunc) ||
(xmlGenericError == NULL))
initGenericErrorDefaultFunc(NULL);
xmlInitGlobals();
xmlInitThreads();
xmlInitMemory();
xmlInitCharEncodingHandlers();
xmlDefaultSAXHandlerInit();
xmlRegisterDefaultInputCallbacks();
#ifdef LIBXML_THREAD_ENABLED
__xmlGlobalInitMutexLock();
if (xmlParserInitialized == 0) {
#endif
if ((xmlGenericError == xmlGenericErrorDefaultFunc) ||
(xmlGenericError == NULL))
initGenericErrorDefaultFunc(NULL);
xmlInitGlobals();
xmlInitThreads();
xmlInitMemory();
xmlInitCharEncodingHandlers();
xmlDefaultSAXHandlerInit();
xmlRegisterDefaultInputCallbacks();
#ifdef LIBXML_OUTPUT_ENABLED
xmlRegisterDefaultOutputCallbacks();
xmlRegisterDefaultOutputCallbacks();
#endif /* LIBXML_OUTPUT_ENABLED */
#ifdef LIBXML_HTML_ENABLED
htmlInitAutoClose();
htmlDefaultSAXHandlerInit();
htmlInitAutoClose();
htmlDefaultSAXHandlerInit();
#endif
#ifdef LIBXML_XPATH_ENABLED
xmlXPathInit();
xmlXPathInit();
#endif
xmlParserInitialized = 1;
#ifdef LIBXML_THREAD_ENABLED
}
__xmlGlobalInitMutexUnlock();
#endif
xmlParserInitialized = 1;
}
/**
......
......@@ -1074,6 +1074,7 @@ Class xmlTextReader(xmlTextReaderCore)
SchemaValidateCtxt()
SetParserProp()
SetSchema()
Setup()
Standalone()
String()
Value()
......@@ -1124,6 +1125,7 @@ Class inputBuffer(ioReadWrapper)
read()
# functions from module xmlreader
Setup()
newTextReader()
......
......@@ -139,6 +139,7 @@ struct _xmlRMutex {
static pthread_key_t globalkey;
static pthread_t mainthread;
static pthread_once_t once_control = PTHREAD_ONCE_INIT;
static pthread_mutex_t global_init_lock = PTHREAD_MUTEX_INITIALIZER;
#elif defined HAVE_WIN32_THREADS
#if defined(HAVE_COMPILER_TLS)
static __declspec(thread) xmlGlobalState tlstate;
......@@ -152,11 +153,14 @@ static struct
DWORD done;
DWORD control;
} run_once = { 0, 0 };
static volatile LPCRITICAL_SECTION global_init_lock = NULL;
/* endif HAVE_WIN32_THREADS */
#elif defined HAVE_BEOS_THREADS
int32 globalkey = 0;
thread_id mainthread = 0;
int32 run_once_init = 0;
static int32 global_init_lock = -1;
static vint32 global_init_count = 0;
#endif
static xmlRMutexPtr xmlLibraryLock = NULL;
......@@ -413,6 +417,85 @@ xmlRMutexUnlock(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
#endif
}
/**
* xmlGlobalInitMutexLock
*
* Makes sure that the global initialization mutex is initialized and
* locks it.
*/
void
__xmlGlobalInitMutexLock(void)
{
/* Make sure the global init lock is initialized and then lock it. */
#ifdef HAVE_PTHREAD_H
int err;
/* The mutex is statically initialized, so we just lock it. */
pthread_mutex_lock(&global_init_lock);
#elif defined HAVE_WIN32_THREADS
LPCRITICAL_SECTION cs;
/* Create a new critical section */
if (global_init_lock == NULL) {
cs = malloc(sizeof(CRITICAL_SECTION));
InitializeCriticalSection(cs);
/* Swap it into the global_init_lock */
InterlockedCompareExchangePointer(&global_init_lock, cs, NULL);
/* If another thread successfully recorded its critical
* section in the global_init_lock then discard the one
* allocated by this thread. */
if (global_init_lock != cs) {
free(cs);
}
}
/* Lock the chosen critical section */
EnterCriticalSection(global_init_lock);
#elif defined HAVE_BEOS_THREADS
int32 sem;
/* Allocate a new semaphore */
sem = create_sem(1, "xmlGlobalinitMutex");
while (global_init_lock == -1) {
if (atomic_add(&global_init_count, 1) == 0) {
global_init_lock = sem;
} else {
snooze(1);
atomic_add(&global_init_count, -1);
}
}
/* If another thread successfully recorded its critical
* section in the global_init_lock then discard the one
* allocated by this thread. */
if (global_init_lock != sem)
delete_sem(sem);
/* Acquire the chosen semaphore */
if (acquire_sem(global_init_lock) != B_NO_ERROR) {
#ifdef DEBUG_THREADS
xmlGenericError(xmlGenericErrorContext, "xmlGlobalInitMutexLock():BeOS:Couldn't acquire semaphore\n");
exit();
#endif
}
#endif
}
void
__xmlGlobalInitMutexUnlock(void)
{
#ifdef HAVE_PTHREAD_H
pthread_mutex_unlock(&global_init_lock);
#elif defined HAVE_WIN32_THREADS
LeaveCriticalSection(global_init_lock);
#elif defined HAVE_BEOS_THREADS
release_sem(global_init_lock);
#endif
}
/************************************************************************
* *
* Per thread global state handling *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment