summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/threads/mttest.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/threads/mttest.c')
-rw-r--r--src/lib/libcrypto/threads/mttest.c119
1 files changed, 33 insertions, 86 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