]> git.pld-linux.org Git - packages/ElectricFence.git/blob - ElectricFence-pthread.patch
-ac_am.patch: removal of ef.sh dropped
[packages/ElectricFence.git] / ElectricFence-pthread.patch
1  * Mon Feb 03 2003 Jakub Jelinek <jakub@redhat.com>
2  - never call semaphore routines in between
3    __libc_malloc_pthread_startup(true) and
4    __libc_malloc_pthread_startup(false) (#83111)
5  - only use semaphore locking if application or its dependencies
6    are linked against -lpthread, don't link libefence.so against
7    -lpthread
8
9 --- ElectricFence-2.2.2/efence.c.jj     1999-04-12 21:00:49.000000000 -0400
10 +++ ElectricFence-2.2.2/efence.c        2003-02-03 11:20:18.000000000 -0500
11 @@ -174,6 +174,15 @@ static int         internalUse = 0;
12  static int             noAllocationListProtection = 0;
13  
14  #ifdef USE_SEMAPHORE
15 +
16 +#include <stdbool.h>
17 +
18 +#pragma weak sem_init
19 +#pragma weak sem_post
20 +#pragma weak sem_wait
21 +
22 +static int             pthread_initialization = 0;
23 +
24  /*
25   * EF_sem is a semaphore used to allow one thread at a time into
26   * these routines.
27 @@ -274,7 +283,7 @@ initialize(void)
28         EF_Print(version);
29  
30  #ifdef USE_SEMAPHORE
31 -       if (sem_init(&EF_sem, 0, 1) >= 0) {
32 +       if (sem_init != NULL && !pthread_initialization && sem_init(&EF_sem, 0, 1) >= 0) {
33                 semEnabled = 1;
34         }
35  #endif
36 @@ -397,6 +406,21 @@ initialize(void)
37         release();
38  }
39  
40 +#ifdef USE_SEMAPHORE
41 +void
42 +__libc_malloc_pthread_startup (bool first_time)
43 +{
44 +       if (first_time) {
45 +               pthread_initialization = 1;
46 +               initialize ();
47 +       } else {
48 +               pthread_initialization = 0;
49 +               if (!semEnabled && sem_init != NULL && sem_init(&EF_sem, 0, 1) >= 0)
50 +                       semEnabled = 1;
51 +       }
52 +}
53 +#endif
54 +
55  /*
56   * allocateMoreSlots is called when there are only enough slot structures
57   * left to support the allocation of a single malloc buffer.
This page took 0.076234 seconds and 3 git commands to generate.