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