summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/threads
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/threads')
-rw-r--r--src/lib/libcrypto/threads/mttest.c119
-rw-r--r--src/lib/libcrypto/threads/th-lock.c79
2 files changed, 57 insertions, 141 deletions
diff --git a/src/lib/libcrypto/threads/mttest.c b/src/lib/libcrypto/threads/mttest.c
index be395f2bc4..142623edda 100644
--- a/src/lib/libcrypto/threads/mttest.c
+++ b/src/lib/libcrypto/threads/mttest.c
@@ -74,13 +74,13 @@
74#include <ulocks.h> 74#include <ulocks.h>
75#include <sys/prctl.h> 75#include <sys/prctl.h>
76#endif 76#endif
77#include "lhash.h" 77#include <openssl/lhash.h>
78#include "crypto.h" 78#include <openssl/crypto.h>
79#include "buffer.h" 79#include <openssl/buffer.h>
80#include "../e_os.h" 80#include "../e_os.h"
81#include "x509.h" 81#include <openssl/x509.h>
82#include "ssl.h" 82#include <openssl/ssl.h>
83#include "err.h" 83#include <openssl/err.h>
84 84
85#ifdef NO_FP_API 85#ifdef NO_FP_API
86#define APPS_WIN16 86#define APPS_WIN16
@@ -92,7 +92,6 @@
92 92
93#define MAX_THREAD_NUMBER 100 93#define MAX_THREAD_NUMBER 100
94 94
95#ifndef NOPROTO
96int MS_CALLBACK verify_callback(int ok, X509 *xs, X509 *xi, int depth, 95int MS_CALLBACK verify_callback(int ok, X509 *xs, X509 *xi, int depth,
97 int error,char *arg); 96 int error,char *arg);
98void thread_setup(void); 97void thread_setup(void);
@@ -108,23 +107,6 @@ unsigned long irix_thread_id(void );
108unsigned long solaris_thread_id(void ); 107unsigned long solaris_thread_id(void );
109unsigned long pthreads_thread_id(void ); 108unsigned long pthreads_thread_id(void );
110 109
111#else
112int MS_CALLBACK verify_callback();
113void thread_setup();
114void thread_cleanup();
115void do_threads();
116
117void irix_locking_callback();
118void solaris_locking_callback();
119void win32_locking_callback();
120void pthreads_locking_callback();
121
122unsigned long irix_thread_id();
123unsigned long solaris_thread_id();
124unsigned long pthreads_thread_id();
125
126#endif
127
128BIO *bio_err=NULL; 110BIO *bio_err=NULL;
129BIO *bio_stdout=NULL; 111BIO *bio_stdout=NULL;
130 112
@@ -139,15 +121,8 @@ int number_of_loops=10;
139int reconnect=0; 121int reconnect=0;
140int cache_stats=0; 122int cache_stats=0;
141 123
142#ifndef NOPROTO
143int doit(char *ctx[4]); 124int doit(char *ctx[4]);
144#else 125static void print_stats(FILE *fp, SSL_CTX *ctx)
145int doit();
146#endif
147
148static void print_stats(fp,ctx)
149FILE *fp;
150SSL_CTX *ctx;
151{ 126{
152 fprintf(fp,"%4ld items in the session cache\n", 127 fprintf(fp,"%4ld items in the session cache\n",
153 SSL_CTX_sess_number(ctx)); 128 SSL_CTX_sess_number(ctx));
@@ -164,7 +139,7 @@ SSL_CTX *ctx;
164 fprintf(fp,"%4d session cache timeouts\n",SSL_CTX_sess_timeouts(ctx)); 139 fprintf(fp,"%4d session cache timeouts\n",SSL_CTX_sess_timeouts(ctx));
165 } 140 }
166 141
167static void sv_usage() 142static void sv_usage(void)
168 { 143 {
169 fprintf(stderr,"usage: ssltest [args ...]\n"); 144 fprintf(stderr,"usage: ssltest [args ...]\n");
170 fprintf(stderr,"\n"); 145 fprintf(stderr,"\n");
@@ -182,9 +157,7 @@ static void sv_usage()
182 fprintf(stderr," -ssl3 - just SSLv3n\n"); 157 fprintf(stderr," -ssl3 - just SSLv3n\n");
183 } 158 }
184 159
185int main(argc, argv) 160int main(int argc, char *argv[])
186int argc;
187char *argv[];
188 { 161 {
189 char *CApath=NULL,*CAfile=NULL; 162 char *CApath=NULL,*CAfile=NULL;
190 int badop=0; 163 int badop=0;
@@ -358,8 +331,7 @@ end:
358#define C_DONE 1 331#define C_DONE 1
359#define S_DONE 2 332#define S_DONE 2
360 333
361int ndoit(ssl_ctx) 334int ndoit(SSL_CTX *ssl_ctx[2])
362SSL_CTX *ssl_ctx[2];
363 { 335 {
364 int i; 336 int i;
365 int ret; 337 int ret;
@@ -405,8 +377,7 @@ SSL_CTX *ssl_ctx[2];
405 return(0); 377 return(0);
406 } 378 }
407 379
408int doit(ctx) 380int doit(char *ctx[4])
409char *ctx[4];
410 { 381 {
411 SSL_CTX *s_ctx,*c_ctx; 382 SSL_CTX *s_ctx,*c_ctx;
412 static char cbuf[200],sbuf[200]; 383 static char cbuf[200],sbuf[200];
@@ -681,13 +652,8 @@ err:
681 return(0); 652 return(0);
682 } 653 }
683 654
684int MS_CALLBACK verify_callback(ok, xs, xi, depth, error, arg) 655int MS_CALLBACK verify_callback(int ok, X509 *xs, X509 *xi, int depth,
685int ok; 656 int error, char *arg)
686X509 *xs;
687X509 *xi;
688int depth;
689int error;
690char *arg;
691 { 657 {
692 char buf[256]; 658 char buf[256];
693 659
@@ -708,7 +674,7 @@ char *arg;
708 674
709static HANDLE lock_cs[CRYPTO_NUM_LOCKS]; 675static HANDLE lock_cs[CRYPTO_NUM_LOCKS];
710 676
711void thread_setup() 677void thread_setup(void)
712 { 678 {
713 int i; 679 int i;
714 680
@@ -721,7 +687,7 @@ void thread_setup()
721 /* id callback defined */ 687 /* id callback defined */
722 } 688 }
723 689
724void thread_cleanup() 690void thread_cleanup(void)
725 { 691 {
726 int i; 692 int i;
727 693
@@ -730,11 +696,7 @@ void thread_cleanup()
730 CloseHandle(lock_cs[i]); 696 CloseHandle(lock_cs[i]);
731 } 697 }
732 698
733void win32_locking_callback(mode,type,file,line) 699void win32_locking_callback(int mode, int type, char *file, int line)
734int mode;
735int type;
736char *file;
737int line;
738 { 700 {
739 if (mode & CRYPTO_LOCK) 701 if (mode & CRYPTO_LOCK)
740 { 702 {
@@ -746,8 +708,7 @@ int line;
746 } 708 }
747 } 709 }
748 710
749void do_threads(s_ctx,c_ctx) 711void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx)
750SSL_CTX *s_ctx,*c_ctx;
751 { 712 {
752 double ret; 713 double ret;
753 SSL_CTX *ssl_ctx[2]; 714 SSL_CTX *ssl_ctx[2];
@@ -806,7 +767,7 @@ static mutex_t lock_cs[CRYPTO_NUM_LOCKS];
806/*static rwlock_t lock_cs[CRYPTO_NUM_LOCKS]; */ 767/*static rwlock_t lock_cs[CRYPTO_NUM_LOCKS]; */
807static long lock_count[CRYPTO_NUM_LOCKS]; 768static long lock_count[CRYPTO_NUM_LOCKS];
808 769
809void thread_setup() 770void thread_setup(void)
810 { 771 {
811 int i; 772 int i;
812 773
@@ -821,7 +782,7 @@ void thread_setup()
821 CRYPTO_set_locking_callback((void (*)())solaris_locking_callback); 782 CRYPTO_set_locking_callback((void (*)())solaris_locking_callback);
822 } 783 }
823 784
824void thread_cleanup() 785void thread_cleanup(void)
825 { 786 {
826 int i; 787 int i;
827 788
@@ -836,11 +797,7 @@ fprintf(stderr,"cleanup\n");
836fprintf(stderr,"done cleanup\n"); 797fprintf(stderr,"done cleanup\n");
837 } 798 }
838 799
839void solaris_locking_callback(mode,type,file,line) 800void solaris_locking_callback(int mode, int type, char *file, int line)
840int mode;
841int type;
842char *file;
843int line;
844 { 801 {
845#ifdef undef 802#ifdef undef
846fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n", 803fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n",
@@ -872,8 +829,7 @@ if (CRYPTO_LOCK_SSL_CERT == type)
872 } 829 }
873 } 830 }
874 831
875void do_threads(s_ctx,c_ctx) 832void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx)
876SSL_CTX *s_ctx,*c_ctx;
877 { 833 {
878 SSL_CTX *ssl_ctx[2]; 834 SSL_CTX *ssl_ctx[2];
879 thread_t thread_ctx[MAX_THREAD_NUMBER]; 835 thread_t thread_ctx[MAX_THREAD_NUMBER];
@@ -902,7 +858,7 @@ SSL_CTX *s_ctx,*c_ctx;
902 s_ctx->references,c_ctx->references); 858 s_ctx->references,c_ctx->references);
903 } 859 }
904 860
905unsigned long solaris_thread_id() 861unsigned long solaris_thread_id(void)
906 { 862 {
907 unsigned long ret; 863 unsigned long ret;
908 864
@@ -917,7 +873,7 @@ unsigned long solaris_thread_id()
917static usptr_t *arena; 873static usptr_t *arena;
918static usema_t *lock_cs[CRYPTO_NUM_LOCKS]; 874static usema_t *lock_cs[CRYPTO_NUM_LOCKS];
919 875
920void thread_setup() 876void thread_setup(void)
921 { 877 {
922 int i; 878 int i;
923 char filename[20]; 879 char filename[20];
@@ -941,7 +897,7 @@ void thread_setup()
941 CRYPTO_set_locking_callback((void (*)())irix_locking_callback); 897 CRYPTO_set_locking_callback((void (*)())irix_locking_callback);
942 } 898 }
943 899
944void thread_cleanup() 900void thread_cleanup(void)
945 { 901 {
946 int i; 902 int i;
947 903
@@ -956,11 +912,7 @@ void thread_cleanup()
956 } 912 }
957 } 913 }
958 914
959void irix_locking_callback(mode,type,file,line) 915void irix_locking_callback(int mode, int type, char *file, int line)
960int mode;
961int type;
962char *file;
963int line;
964 { 916 {
965 if (mode & CRYPTO_LOCK) 917 if (mode & CRYPTO_LOCK)
966 { 918 {
@@ -974,8 +926,7 @@ int line;
974 } 926 }
975 } 927 }
976 928
977void do_threads(s_ctx,c_ctx) 929void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx)
978SSL_CTX *s_ctx,*c_ctx;
979 { 930 {
980 SSL_CTX *ssl_ctx[2]; 931 SSL_CTX *ssl_ctx[2];
981 int thread_ctx[MAX_THREAD_NUMBER]; 932 int thread_ctx[MAX_THREAD_NUMBER];
@@ -1000,7 +951,7 @@ SSL_CTX *s_ctx,*c_ctx;
1000 s_ctx->references,c_ctx->references); 951 s_ctx->references,c_ctx->references);
1001 } 952 }
1002 953
1003unsigned long irix_thread_id() 954unsigned long irix_thread_id(void)
1004 { 955 {
1005 unsigned long ret; 956 unsigned long ret;
1006 957
@@ -1014,7 +965,7 @@ unsigned long irix_thread_id()
1014static pthread_mutex_t lock_cs[CRYPTO_NUM_LOCKS]; 965static pthread_mutex_t lock_cs[CRYPTO_NUM_LOCKS];
1015static long lock_count[CRYPTO_NUM_LOCKS]; 966static long lock_count[CRYPTO_NUM_LOCKS];
1016 967
1017void thread_setup() 968void thread_setup(void)
1018 { 969 {
1019 int i; 970 int i;
1020 971
@@ -1028,7 +979,7 @@ void thread_setup()
1028 CRYPTO_set_locking_callback((void (*)())pthreads_locking_callback); 979 CRYPTO_set_locking_callback((void (*)())pthreads_locking_callback);
1029 } 980 }
1030 981
1031void thread_cleanup() 982void thread_cleanup(void)
1032 { 983 {
1033 int i; 984 int i;
1034 985
@@ -1043,11 +994,8 @@ void thread_cleanup()
1043 fprintf(stderr,"done cleanup\n"); 994 fprintf(stderr,"done cleanup\n");
1044 } 995 }
1045 996
1046void pthreads_locking_callback(mode,type,file,line) 997void pthreads_locking_callback(int mode, int type, char *file,
1047int mode; 998 int line)
1048int type;
1049char *file;
1050int line;
1051 { 999 {
1052#ifdef undef 1000#ifdef undef
1053 fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n", 1001 fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n",
@@ -1072,8 +1020,7 @@ int line;
1072 } 1020 }
1073 } 1021 }
1074 1022
1075void do_threads(s_ctx,c_ctx) 1023void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx)
1076SSL_CTX *s_ctx,*c_ctx;
1077 { 1024 {
1078 SSL_CTX *ssl_ctx[2]; 1025 SSL_CTX *ssl_ctx[2];
1079 pthread_t thread_ctx[MAX_THREAD_NUMBER]; 1026 pthread_t thread_ctx[MAX_THREAD_NUMBER];
@@ -1101,7 +1048,7 @@ SSL_CTX *s_ctx,*c_ctx;
1101 s_ctx->references,c_ctx->references); 1048 s_ctx->references,c_ctx->references);
1102 } 1049 }
1103 1050
1104unsigned long pthreads_thread_id() 1051unsigned long pthreads_thread_id(void)
1105 { 1052 {
1106 unsigned long ret; 1053 unsigned long ret;
1107 1054
diff --git a/src/lib/libcrypto/threads/th-lock.c b/src/lib/libcrypto/threads/th-lock.c
index 039022446d..afb4f4caf2 100644
--- a/src/lib/libcrypto/threads/th-lock.c
+++ b/src/lib/libcrypto/threads/th-lock.c
@@ -74,15 +74,14 @@
74#include <ulocks.h> 74#include <ulocks.h>
75#include <sys/prctl.h> 75#include <sys/prctl.h>
76#endif 76#endif
77#include "lhash.h" 77#include <openssl/lhash.h>
78#include "crypto.h" 78#include <openssl/crypto.h>
79#include "buffer.h" 79#include <openssl/buffer.h>
80#include "e_os.h" 80#include <openssl/e_os.h>
81#include "x509.h" 81#include <openssl/x509.h>
82#include "ssl.h" 82#include <openssl/ssl.h>
83#include "err.h" 83#include <openssl/err.h>
84 84
85#ifndef NOPROTO
86int CRYPTO_thread_setup(void); 85int CRYPTO_thread_setup(void);
87void CRYPTO_thread_cleanup(void); 86void CRYPTO_thread_cleanup(void);
88 87
@@ -95,21 +94,6 @@ static unsigned long irix_thread_id(void );
95static unsigned long solaris_thread_id(void ); 94static unsigned long solaris_thread_id(void );
96static unsigned long pthreads_thread_id(void ); 95static unsigned long pthreads_thread_id(void );
97 96
98#else
99int CRYPOTO_thread_setup();
100void CRYPTO_cleanup();
101
102static void irix_locking_callback();
103static void solaris_locking_callback();
104static void win32_locking_callback();
105static void pthreads_locking_callback();
106
107static unsigned long irix_thread_id();
108static unsigned long solaris_thread_id();
109static unsigned long pthreads_thread_id();
110
111#endif
112
113/* usage: 97/* usage:
114 * CRYPTO_thread_setup(); 98 * CRYPTO_thread_setup();
115 * applicaion code 99 * applicaion code
@@ -122,7 +106,7 @@ static unsigned long pthreads_thread_id();
122 106
123static HANDLE lock_cs[CRYPTO_NUM_LOCKS]; 107static HANDLE lock_cs[CRYPTO_NUM_LOCKS];
124 108
125int CRYPTO_thread_setup() 109int CRYPTO_thread_setup(void)
126 { 110 {
127 int i; 111 int i;
128 112
@@ -136,7 +120,7 @@ int CRYPTO_thread_setup()
136 return(1); 120 return(1);
137 } 121 }
138 122
139static void CRYPTO_thread_cleanup() 123static void CRYPTO_thread_cleanup(void)
140 { 124 {
141 int i; 125 int i;
142 126
@@ -145,11 +129,7 @@ static void CRYPTO_thread_cleanup()
145 CloseHandle(lock_cs[i]); 129 CloseHandle(lock_cs[i]);
146 } 130 }
147 131
148void win32_locking_callback(mode,type,file,line) 132void win32_locking_callback(int mode, int type, char *file, int line)
149int mode;
150int type;
151char *file;
152int line;
153 { 133 {
154 if (mode & CRYPTO_LOCK) 134 if (mode & CRYPTO_LOCK)
155 { 135 {
@@ -174,7 +154,7 @@ static long lock_count[CRYPTO_NUM_LOCKS];
174static rwlock_t lock_cs[CRYPTO_NUM_LOCKS]; 154static rwlock_t lock_cs[CRYPTO_NUM_LOCKS];
175#endif 155#endif
176 156
177void CRYPTO_thread_setup() 157void CRYPTO_thread_setup(void)
178 { 158 {
179 int i; 159 int i;
180 160
@@ -192,7 +172,7 @@ void CRYPTO_thread_setup()
192 CRYPTO_set_locking_callback((void (*)())solaris_locking_callback); 172 CRYPTO_set_locking_callback((void (*)())solaris_locking_callback);
193 } 173 }
194 174
195void CRYPTO_thread_cleanup() 175void CRYPTO_thread_cleanup(void)
196 { 176 {
197 int i; 177 int i;
198 178
@@ -207,11 +187,7 @@ void CRYPTO_thread_cleanup()
207 } 187 }
208 } 188 }
209 189
210void solaris_locking_callback(mode,type,file,line) 190void solaris_locking_callback(int mode, int type, char *file, int line)
211int mode;
212int type;
213char *file;
214int line;
215 { 191 {
216#if 0 192#if 0
217 fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n", 193 fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n",
@@ -248,7 +224,7 @@ int line;
248 } 224 }
249 } 225 }
250 226
251unsigned long solaris_thread_id() 227unsigned long solaris_thread_id(void)
252 { 228 {
253 unsigned long ret; 229 unsigned long ret;
254 230
@@ -263,7 +239,7 @@ unsigned long solaris_thread_id()
263static usptr_t *arena; 239static usptr_t *arena;
264static usema_t *lock_cs[CRYPTO_NUM_LOCKS]; 240static usema_t *lock_cs[CRYPTO_NUM_LOCKS];
265 241
266void CRYPTO_thread_setup() 242void CRYPTO_thread_setup(void)
267 { 243 {
268 int i; 244 int i;
269 char filename[20]; 245 char filename[20];
@@ -287,7 +263,7 @@ void CRYPTO_thread_setup()
287 CRYPTO_set_locking_callback((void (*)())irix_locking_callback); 263 CRYPTO_set_locking_callback((void (*)())irix_locking_callback);
288 } 264 }
289 265
290void CRYPTO_thread_cleanup() 266void CRYPTO_thread_cleanup(void)
291 { 267 {
292 int i; 268 int i;
293 269
@@ -302,11 +278,7 @@ void CRYPTO_thread_cleanup()
302 } 278 }
303 } 279 }
304 280
305void irix_locking_callback(mode,type,file,line) 281void irix_locking_callback(int mode, int type, char *file, int line)
306int mode;
307int type;
308char *file;
309int line;
310 { 282 {
311 if (mode & CRYPTO_LOCK) 283 if (mode & CRYPTO_LOCK)
312 { 284 {
@@ -318,7 +290,7 @@ int line;
318 } 290 }
319 } 291 }
320 292
321unsigned long irix_thread_id() 293unsigned long irix_thread_id(void)
322 { 294 {
323 unsigned long ret; 295 unsigned long ret;
324 296
@@ -333,7 +305,7 @@ unsigned long irix_thread_id()
333static pthread_mutex_t lock_cs[CRYPTO_NUM_LOCKS]; 305static pthread_mutex_t lock_cs[CRYPTO_NUM_LOCKS];
334static long lock_count[CRYPTO_NUM_LOCKS]; 306static long lock_count[CRYPTO_NUM_LOCKS];
335 307
336void CRYPTO_thread_setup() 308void CRYPTO_thread_setup(void)
337 { 309 {
338 int i; 310 int i;
339 311
@@ -347,7 +319,7 @@ void CRYPTO_thread_setup()
347 CRYPTO_set_locking_callback((void (*)())pthreads_locking_callback); 319 CRYPTO_set_locking_callback((void (*)())pthreads_locking_callback);
348 } 320 }
349 321
350void thread_cleanup() 322void thread_cleanup(void)
351 { 323 {
352 int i; 324 int i;
353 325
@@ -358,11 +330,8 @@ void thread_cleanup()
358 } 330 }
359 } 331 }
360 332
361void pthreads_locking_callback(mode,type,file,line) 333void pthreads_locking_callback(int mode, int type, char *file,
362int mode; 334 int line)
363int type;
364char *file;
365int line;
366 { 335 {
367#if 0 336#if 0
368 fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n", 337 fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n",
@@ -387,7 +356,7 @@ int line;
387 } 356 }
388 } 357 }
389 358
390unsigned long pthreads_thread_id() 359unsigned long pthreads_thread_id(void)
391 { 360 {
392 unsigned long ret; 361 unsigned long ret;
393 362