]> git.pld-linux.org Git - packages/ElectricFence.git/commitdiff
- semaphore-related crash fix (from FC)
authorJakub Bogusz <qboosh@pld-linux.org>
Sun, 20 Feb 2005 21:19:44 +0000 (21:19 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    ElectricFence-pthread.patch -> 1.1

ElectricFence-pthread.patch [new file with mode: 0644]

diff --git a/ElectricFence-pthread.patch b/ElectricFence-pthread.patch
new file mode 100644 (file)
index 0000000..8e6c735
--- /dev/null
@@ -0,0 +1,57 @@
+ * Mon Feb 03 2003 Jakub Jelinek <jakub@redhat.com>
+ - never call semaphore routines in between
+   __libc_malloc_pthread_startup(true) and
+   __libc_malloc_pthread_startup(false) (#83111)
+ - only use semaphore locking if application or its dependencies
+   are linked against -lpthread, don't link libefence.so against
+   -lpthread
+
+--- ElectricFence-2.2.2/efence.c.jj    1999-04-12 21:00:49.000000000 -0400
++++ ElectricFence-2.2.2/efence.c       2003-02-03 11:20:18.000000000 -0500
+@@ -174,6 +174,15 @@ static int                internalUse = 0;
+ static int            noAllocationListProtection = 0;
+ #ifdef USE_SEMAPHORE
++
++#include <stdbool.h>
++
++#pragma weak sem_init
++#pragma weak sem_post
++#pragma weak sem_wait
++
++static int            pthread_initialization = 0;
++
+ /*
+  * EF_sem is a semaphore used to allow one thread at a time into
+  * these routines.
+@@ -274,7 +283,7 @@ initialize(void)
+       EF_Print(version);
+ #ifdef USE_SEMAPHORE
+-      if (sem_init(&EF_sem, 0, 1) >= 0) {
++      if (sem_init != NULL && !pthread_initialization && sem_init(&EF_sem, 0, 1) >= 0) {
+               semEnabled = 1;
+       }
+ #endif
+@@ -397,6 +406,21 @@ initialize(void)
+       release();
+ }
++#ifdef USE_SEMAPHORE
++void
++__libc_malloc_pthread_startup (bool first_time)
++{
++      if (first_time) {
++              pthread_initialization = 1;
++              initialize ();
++      } else {
++              pthread_initialization = 0;
++              if (!semEnabled && sem_init != NULL && sem_init(&EF_sem, 0, 1) >= 0)
++                      semEnabled = 1;
++      }
++}
++#endif
++
+ /*
+  * allocateMoreSlots is called when there are only enough slot structures
+  * left to support the allocation of a single malloc buffer.
This page took 0.141756 seconds and 4 git commands to generate.