components/stunnel/patches/stunnel-4.56-CRYPTO_num_locks.patch
branchs11-update
changeset 2723 138732f62341
equal deleted inserted replaced
2722:dc566ca73390 2723:138732f62341
       
     1 # stunnel should use CRYPTO_num_locks() function instead of CRYPTO_NUM_LOCKS
       
     2 # macro.  The function interogates libcrypto at run-time for sizing and the
       
     3 # macro at compile time.  If you interpose a a version at runtime to switch
       
     4 # between FIPS/non-FIPS support, the lock table may not be sized correctly.
       
     5 #
       
     6 diff -r -u stunnel-4.55.orig/src/sthreads.c stunnel-4.55/src/sthreads.c
       
     7 --- stunnel-4.55.orig/src/sthreads.c	2012-08-09 14:44:18.000000000 -0700
       
     8 +++ stunnel-4.55/src/sthreads.c	2013-03-21 23:29:34.912001586 -0700
       
     9 @@ -212,7 +212,7 @@
       
    10  #ifdef USE_PTHREAD
       
    11  
       
    12  static pthread_mutex_t stunnel_cs[CRIT_SECTIONS];
       
    13 -static pthread_mutex_t lock_cs[CRYPTO_NUM_LOCKS];
       
    14 +static pthread_mutex_t *lock_cs;
       
    15  
       
    16  void enter_critical_section(SECTION_CODE i) {
       
    17      pthread_mutex_lock(stunnel_cs+i);
       
    18 @@ -275,13 +275,15 @@
       
    19  
       
    20  int sthreads_init(void) {
       
    21      int i;
       
    22 +    int num_locks = CRYPTO_num_locks();
       
    23  
       
    24      /* initialize stunnel critical sections */
       
    25      for(i=0; i<CRIT_SECTIONS; i++)
       
    26          pthread_mutex_init(stunnel_cs+i, NULL);
       
    27  
       
    28      /* initialize OpenSSL locking callback */
       
    29 -    for(i=0; i<CRYPTO_NUM_LOCKS; i++)
       
    30 +    lock_cs = calloc(num_locks, sizeof (*lock_cs));
       
    31 +    for(i=0; i<num_locks; i++)
       
    32          pthread_mutex_init(lock_cs+i, NULL);
       
    33      CRYPTO_set_id_callback(stunnel_thread_id);
       
    34      CRYPTO_set_locking_callback(locking_callback);