Fix a locking bug in 1.1.25, daniel

This commit is contained in:
Daniel Veillard 2009-09-21 09:09:50 +00:00
parent 5f935fa181
commit 80a6df1bb3
2 changed files with 132 additions and 2 deletions

View File

@ -0,0 +1,125 @@
commit 2e8defa7ccef2f76fb1cbfe9e9673d8e4b6cf1d6
Author: Daniel Veillard <veillard@redhat.com>
Date: Sun Sep 20 11:51:52 2009 +0200
595612 Try to fix some locking problems
* libxslt/extensions.c: there were still cases where the normal
code path could led to trying to mtake again the extension lock
go over all entry points of the module and clean things up
diff --git a/libxslt/extensions.c b/libxslt/extensions.c
index ebb81f5..6187b7a 100644
--- a/libxslt/extensions.c
+++ b/libxslt/extensions.c
@@ -313,8 +313,6 @@ typedef void (*exsltRegisterFunction) (void);
* by LIBXSLT_DEFAULT_PLUGINS_PATH() which is determined at
* compile time.
*
- * Always called with xsltExtMutex lock taken.
- *
* Returns 0 if successful, -1 in case of error.
*/
@@ -550,10 +548,14 @@ xsltRegisterExtPrefix(xsltStylesheetPtr style,
if (xsltExtensionsHash != NULL) {
xsltExtModulePtr module;
+ xmlMutexLock(xsltExtMutex);
module = xmlHashLookup(xsltExtensionsHash, URI);
+ xmlMutexUnlock(xsltExtMutex);
if (NULL == module) {
if (!xsltExtModuleRegisterDynamic(URI)) {
+ xmlMutexLock(xsltExtMutex);
module = xmlHashLookup(xsltExtensionsHash, URI);
+ xmlMutexUnlock(xsltExtMutex);
}
}
if (module != NULL) {
@@ -1669,18 +1671,13 @@ xsltExtElementLookup(xsltTransformContextPtr ctxt,
if ((name == NULL) || (URI == NULL))
return (NULL);
- xmlMutexLock(xsltExtMutex);
-
if ((ctxt != NULL) && (ctxt->extElements != NULL)) {
XML_CAST_FPTR(ret) = xmlHashLookup2(ctxt->extElements, name, URI);
if (ret != NULL) {
- xmlMutexUnlock(xsltExtMutex);
return(ret);
}
}
- xmlMutexUnlock(xsltExtMutex);
-
ret = xsltExtModuleElementLookup(name, URI);
return (ret);
@@ -1707,19 +1704,23 @@ xsltExtModuleElementLookup(const xmlChar * name, const xmlChar * URI)
ext = (xsltExtElementPtr) xmlHashLookup2(xsltElementsHash, name, URI);
+ xmlMutexUnlock(xsltExtMutex);
+
/*
* if function lookup fails, attempt a dynamic load on
* supported platforms
*/
if (NULL == ext) {
if (!xsltExtModuleRegisterDynamic(URI)) {
+ xmlMutexLock(xsltExtMutex);
+
ext = (xsltExtElementPtr)
xmlHashLookup2(xsltElementsHash, name, URI);
+
+ xmlMutexUnlock(xsltExtMutex);
}
}
- xmlMutexUnlock(xsltExtMutex);
-
if (ext == NULL)
return (NULL);
return (ext->transform);
@@ -1747,13 +1748,18 @@ xsltExtModuleElementPreComputeLookup(const xmlChar * name,
ext = (xsltExtElementPtr) xmlHashLookup2(xsltElementsHash, name, URI);
+ xmlMutexUnlock(xsltExtMutex);
+
if (ext == NULL) {
if (!xsltExtModuleRegisterDynamic(URI)) {
+ xmlMutexLock(xsltExtMutex);
+
ext = (xsltExtElementPtr)
xmlHashLookup2(xsltElementsHash, name, URI);
+
+ xmlMutexUnlock(xsltExtMutex);
}
}
- xmlMutexUnlock(xsltExtMutex);
if (ext == NULL)
return (NULL);
@@ -1856,15 +1862,19 @@ xsltExtModuleTopLevelLookup(const xmlChar * name, const xmlChar * URI)
XML_CAST_FPTR(ret) = xmlHashLookup2(xsltTopLevelsHash, name, URI);
+ xmlMutexUnlock(xsltExtMutex);
+
/* if lookup fails, attempt a dynamic load on supported platforms */
if (NULL == ret) {
if (!xsltExtModuleRegisterDynamic(URI)) {
+ xmlMutexLock(xsltExtMutex);
+
XML_CAST_FPTR(ret) = xmlHashLookup2(xsltTopLevelsHash, name, URI);
+
+ xmlMutexUnlock(xsltExtMutex);
}
}
- xmlMutexUnlock(xsltExtMutex);
-
return (ret);
}

View File

@ -1,7 +1,7 @@
Summary: Library providing the Gnome XSLT engine
Name: libxslt
Version: 1.1.25
Release: 1%{?dist}%{?extra_release}
Release: 2%{?dist}%{?extra_release}
License: MIT
Group: Development/Libraries
Source: ftp://xmlsoft.org/XSLT/libxslt-%{version}.tar.gz
@ -15,6 +15,7 @@ BuildRequires: libgcrypt-devel
Prefix: %{_prefix}
Docdir: %{_docdir}
Patch0: multilib.patch
Patch1: libxslt-1.1.25-locking.patch
%description
This C library allows to transform XML files into other XML files
@ -56,6 +57,7 @@ with XPath functions written in Python.
%prep
%setup -q
%patch0 -p1
%patch1 -p1
%build
%configure
@ -130,7 +132,10 @@ rm -fr %{buildroot}
%doc python/tests/*.xsl
%changelog
* Thu Sep 17 2009 Daniel Veillard <veillard@redhat.com> 1.1.24-1
* Mon Sep 21 2009 Daniel Veillard <veillard@redhat.com> 1.1.25-2
- fix a locking bug in 1.1.25
* Thu Sep 17 2009 Daniel Veillard <veillard@redhat.com> 1.1.25-1
- release of 1.1.25
- Add API versioning for libxslt shared library
- xsl:sort lang support using the locale