View | Details | Raw Unified | Return to bug 171353 | Differences between
and this patch

Collapse All | Expand All

(-)files/patch-threads.c (+39 lines)
Line 0 Link Here
1
--- threads.c.orig	2010-12-20 07:56:24.000000000 -0500
2
+++ threads.c	2013-07-16 12:53:56.000000000 -0400
3
@@ -145,6 +145,7 @@
4
 #ifdef HAVE_PTHREAD_H
5
 static pthread_key_t globalkey;
6
 static pthread_t mainthread;
7
+static pthread_once_t once_init_threads_control = PTHREAD_ONCE_INIT;
8
 static pthread_once_t once_control = PTHREAD_ONCE_INIT;
9
 static pthread_mutex_t global_init_lock = PTHREAD_MUTEX_INITIALIZER;
10
 #elif defined HAVE_WIN32_THREADS
11
@@ -177,6 +178,19 @@
12
 #endif
13
 
14
 /**
15
+ * xmlOnceInitThreads:
16
+ *
17
+ * xmlOnceInitThreads() is used to ensure we have a working threads
18
+ * library with a functioning pthread_once().  Some OSes provide
19
+ * non-working libc stubs for pthread functions.
20
+ */
21
+static void
22
+xmlOnceInitThreads(void)
23
+{
24
+    libxml_is_threaded = 1;
25
+}
26
+
27
+/**
28
  * xmlNewMutex:
29
  *
30
  * xmlNewMutex() is used to allocate a libxml2 token struct for use in
31
@@ -878,7 +892,7 @@
32
             (pthread_equal != NULL) &&
33
             (pthread_self != NULL) &&
34
             (pthread_cond_signal != NULL)) {
35
-            libxml_is_threaded = 1;
36
+            pthread_once(&once_init_threads_control, xmlOnceInitThreads);
37
 
38
 /* fprintf(stderr, "Running multithreaded\n"); */
39
         } else {

Return to bug 171353