autofs-5.0.4 - fix libxml2 non-thread-safe calls From: Ian Kent The libxml2 call xmlCleanupParser() is definitely not thread safe. This patch moves it and the xmlInitParser() call to the location of the code to workaround the libxml2 incorrect TSD handling so they are called only at start and at exit. --- CHANGELOG | 1 + daemon/Makefile | 7 +++++++ daemon/automount.c | 7 ++++++- modules/lookup_ldap.c | 2 -- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4491449..af7792d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -59,6 +59,7 @@ - fix an RPC fd leak. - don't block signals we expect to dump core. - fix pthread push order in expire_proc_direct(). +- fix libxml2 non-thread-safe calls. 4/11/2008 autofs-5.0.4 ----------------------- diff --git a/daemon/Makefile b/daemon/Makefile index 9c2d858..371ec72 100644 --- a/daemon/Makefile +++ b/daemon/Makefile @@ -22,6 +22,13 @@ CFLAGS += -DVERSION_STRING=\"$(version)\" LDFLAGS += -rdynamic LIBS = -ldl +ifeq ($(LDAP), 1) + ifeq ($(SASL), 1) + CFLAGS += $(XML_FLAGS) + LIBS += $(XML_LIBS) + endif +endif + all: automount automount: $(OBJS) $(AUTOFS_LIB) diff --git a/daemon/automount.c b/daemon/automount.c index 6759883..979ecd6 100644 --- a/daemon/automount.c +++ b/daemon/automount.c @@ -40,6 +40,7 @@ #include "automount.h" #ifdef LIBXML2_WORKAROUND #include +#include #endif const char *program; /* Initialized with argv[0] */ @@ -2113,6 +2114,8 @@ int main(int argc, char *argv[]) void *dh_xml2 = dlopen("libxml2.so", RTLD_NOW); if (!dh_xml2) dh_xml2 = dlopen("libxml2.so.2", RTLD_NOW); + if (dh_xml2) + xmlInitParser(); #endif #ifdef TIRPC_WORKAROUND void *dh_tirpc = dlopen("libitirpc.so", RTLD_NOW); @@ -2156,8 +2159,10 @@ int main(int argc, char *argv[]) dlclose(dh_tirpc); #endif #ifdef LIBXML2_WORKAROUND - if (dh_xml2) + if (dh_xml2) { + xmlCleanupParser(); dlclose(dh_xml2); + } #endif close_ioctl_ctl(); diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c index 8f352d6..2ecf5fe 100644 --- a/modules/lookup_ldap.c +++ b/modules/lookup_ldap.c @@ -897,7 +897,6 @@ int parse_ldap_config(unsigned logopt, struct lookup_context *ctxt) return -1; } - xmlInitParser(); doc = xmlParseFile(auth_conf); if (!doc) { error(logopt, MODPREFIX @@ -1069,7 +1068,6 @@ int parse_ldap_config(unsigned logopt, struct lookup_context *ctxt) out: xmlFreeDoc(doc); - xmlCleanupParser(); if (fallback) return 0;