diff options
Diffstat (limited to 'src/lib/libcrypto/threads')
| -rw-r--r-- | src/lib/libcrypto/threads/mttest.c | 115 | ||||
| -rw-r--r-- | src/lib/libcrypto/threads/netware.bat | 79 | ||||
| -rw-r--r-- | src/lib/libcrypto/threads/th-lock.c | 2 |
3 files changed, 80 insertions, 116 deletions
diff --git a/src/lib/libcrypto/threads/mttest.c b/src/lib/libcrypto/threads/mttest.c index f6f3df4b6a..7588966cb2 100644 --- a/src/lib/libcrypto/threads/mttest.c +++ b/src/lib/libcrypto/threads/mttest.c | |||
| @@ -77,12 +77,6 @@ | |||
| 77 | #ifdef PTHREADS | 77 | #ifdef PTHREADS |
| 78 | #include <pthread.h> | 78 | #include <pthread.h> |
| 79 | #endif | 79 | #endif |
| 80 | #ifdef OPENSSL_SYS_NETWARE | ||
| 81 | #if !defined __int64 | ||
| 82 | # define __int64 long long | ||
| 83 | #endif | ||
| 84 | #include <nwmpk.h> | ||
| 85 | #endif | ||
| 86 | #include <openssl/lhash.h> | 80 | #include <openssl/lhash.h> |
| 87 | #include <openssl/crypto.h> | 81 | #include <openssl/crypto.h> |
| 88 | #include <openssl/buffer.h> | 82 | #include <openssl/buffer.h> |
| @@ -92,18 +86,8 @@ | |||
| 92 | #include <openssl/err.h> | 86 | #include <openssl/err.h> |
| 93 | #include <openssl/rand.h> | 87 | #include <openssl/rand.h> |
| 94 | 88 | ||
| 95 | #ifdef OPENSSL_NO_FP_API | ||
| 96 | #define APPS_WIN16 | ||
| 97 | #include "../buffer/bss_file.c" | ||
| 98 | #endif | ||
| 99 | |||
| 100 | #ifdef OPENSSL_SYS_NETWARE | ||
| 101 | #define TEST_SERVER_CERT "/openssl/apps/server.pem" | ||
| 102 | #define TEST_CLIENT_CERT "/openssl/apps/client.pem" | ||
| 103 | #else | ||
| 104 | #define TEST_SERVER_CERT "../../apps/server.pem" | 89 | #define TEST_SERVER_CERT "../../apps/server.pem" |
| 105 | #define TEST_CLIENT_CERT "../../apps/client.pem" | 90 | #define TEST_CLIENT_CERT "../../apps/client.pem" |
| 106 | #endif | ||
| 107 | 91 | ||
| 108 | #define MAX_THREAD_NUMBER 100 | 92 | #define MAX_THREAD_NUMBER 100 |
| 109 | 93 | ||
| @@ -116,18 +100,10 @@ void irix_locking_callback(int mode,int type,char *file,int line); | |||
| 116 | void solaris_locking_callback(int mode,int type,char *file,int line); | 100 | void solaris_locking_callback(int mode,int type,char *file,int line); |
| 117 | void win32_locking_callback(int mode,int type,char *file,int line); | 101 | void win32_locking_callback(int mode,int type,char *file,int line); |
| 118 | void pthreads_locking_callback(int mode,int type,char *file,int line); | 102 | void pthreads_locking_callback(int mode,int type,char *file,int line); |
| 119 | void netware_locking_callback(int mode,int type,char *file,int line); | ||
| 120 | 103 | ||
| 121 | unsigned long irix_thread_id(void ); | 104 | unsigned long irix_thread_id(void ); |
| 122 | unsigned long solaris_thread_id(void ); | 105 | unsigned long solaris_thread_id(void ); |
| 123 | unsigned long pthreads_thread_id(void ); | 106 | unsigned long pthreads_thread_id(void ); |
| 124 | unsigned long netware_thread_id(void ); | ||
| 125 | |||
| 126 | #if defined(OPENSSL_SYS_NETWARE) | ||
| 127 | static MPKMutex *lock_cs; | ||
| 128 | static MPKSema ThreadSem; | ||
| 129 | static long *lock_count; | ||
| 130 | #endif | ||
| 131 | 107 | ||
| 132 | BIO *bio_err=NULL; | 108 | BIO *bio_err=NULL; |
| 133 | BIO *bio_stdout=NULL; | 109 | BIO *bio_stdout=NULL; |
| @@ -408,9 +384,6 @@ int ndoit(SSL_CTX *ssl_ctx[2]) | |||
| 408 | SSL_free((SSL *)ctx[2]); | 384 | SSL_free((SSL *)ctx[2]); |
| 409 | SSL_free((SSL *)ctx[3]); | 385 | SSL_free((SSL *)ctx[3]); |
| 410 | } | 386 | } |
| 411 | # ifdef OPENSSL_SYS_NETWARE | ||
| 412 | MPKSemaphoreSignal(ThreadSem); | ||
| 413 | # endif | ||
| 414 | return(0); | 387 | return(0); |
| 415 | } | 388 | } |
| 416 | 389 | ||
| @@ -654,9 +627,6 @@ int doit(char *ctx[4]) | |||
| 654 | } | 627 | } |
| 655 | 628 | ||
| 656 | if ((done & S_DONE) && (done & C_DONE)) break; | 629 | if ((done & S_DONE) && (done & C_DONE)) break; |
| 657 | # if defined(OPENSSL_SYS_NETWARE) | ||
| 658 | ThreadSwitchWithDelay(); | ||
| 659 | # endif | ||
| 660 | } | 630 | } |
| 661 | 631 | ||
| 662 | SSL_set_shutdown(c_ssl,SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN); | 632 | SSL_set_shutdown(c_ssl,SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN); |
| @@ -1124,88 +1094,3 @@ unsigned long pthreads_thread_id(void) | |||
| 1124 | 1094 | ||
| 1125 | 1095 | ||
| 1126 | 1096 | ||
| 1127 | #ifdef OPENSSL_SYS_NETWARE | ||
| 1128 | |||
| 1129 | void thread_setup(void) | ||
| 1130 | { | ||
| 1131 | int i; | ||
| 1132 | |||
| 1133 | lock_cs=OPENSSL_malloc(CRYPTO_num_locks() * sizeof(MPKMutex)); | ||
| 1134 | lock_count=OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long)); | ||
| 1135 | for (i=0; i<CRYPTO_num_locks(); i++) | ||
| 1136 | { | ||
| 1137 | lock_count[i]=0; | ||
| 1138 | lock_cs[i]=MPKMutexAlloc("OpenSSL mutex"); | ||
| 1139 | } | ||
| 1140 | |||
| 1141 | ThreadSem = MPKSemaphoreAlloc("OpenSSL mttest semaphore", 0 ); | ||
| 1142 | |||
| 1143 | CRYPTO_set_id_callback((unsigned long (*)())netware_thread_id); | ||
| 1144 | CRYPTO_set_locking_callback((void (*)())netware_locking_callback); | ||
| 1145 | } | ||
| 1146 | |||
| 1147 | void thread_cleanup(void) | ||
| 1148 | { | ||
| 1149 | int i; | ||
| 1150 | |||
| 1151 | CRYPTO_set_locking_callback(NULL); | ||
| 1152 | |||
| 1153 | fprintf(stdout,"thread_cleanup\n"); | ||
| 1154 | |||
| 1155 | for (i=0; i<CRYPTO_num_locks(); i++) | ||
| 1156 | { | ||
| 1157 | MPKMutexFree(lock_cs[i]); | ||
| 1158 | fprintf(stdout,"%8ld:%s\n",lock_count[i],CRYPTO_get_lock_name(i)); | ||
| 1159 | } | ||
| 1160 | OPENSSL_free(lock_cs); | ||
| 1161 | OPENSSL_free(lock_count); | ||
| 1162 | |||
| 1163 | MPKSemaphoreFree(ThreadSem); | ||
| 1164 | |||
| 1165 | fprintf(stdout,"done cleanup\n"); | ||
| 1166 | } | ||
| 1167 | |||
| 1168 | void netware_locking_callback(int mode, int type, char *file, int line) | ||
| 1169 | { | ||
| 1170 | if (mode & CRYPTO_LOCK) | ||
| 1171 | { | ||
| 1172 | MPKMutexLock(lock_cs[type]); | ||
| 1173 | lock_count[type]++; | ||
| 1174 | } | ||
| 1175 | else | ||
| 1176 | MPKMutexUnlock(lock_cs[type]); | ||
| 1177 | } | ||
| 1178 | |||
| 1179 | void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx) | ||
| 1180 | { | ||
| 1181 | SSL_CTX *ssl_ctx[2]; | ||
| 1182 | int i; | ||
| 1183 | ssl_ctx[0]=s_ctx; | ||
| 1184 | ssl_ctx[1]=c_ctx; | ||
| 1185 | |||
| 1186 | for (i=0; i<thread_number; i++) | ||
| 1187 | { | ||
| 1188 | BeginThread( (void(*)(void*))ndoit, NULL, THREAD_STACK_SIZE, | ||
| 1189 | (void*)ssl_ctx); | ||
| 1190 | ThreadSwitchWithDelay(); | ||
| 1191 | } | ||
| 1192 | |||
| 1193 | printf("reaping\n"); | ||
| 1194 | |||
| 1195 | /* loop until all threads have signaled the semaphore */ | ||
| 1196 | for (i=0; i<thread_number; i++) | ||
| 1197 | { | ||
| 1198 | MPKSemaphoreWait(ThreadSem); | ||
| 1199 | } | ||
| 1200 | printf("netware threads done (%d,%d)\n", | ||
| 1201 | s_ctx->references,c_ctx->references); | ||
| 1202 | } | ||
| 1203 | |||
| 1204 | unsigned long netware_thread_id(void) | ||
| 1205 | { | ||
| 1206 | unsigned long ret; | ||
| 1207 | |||
| 1208 | ret=(unsigned long)GetThreadID(); | ||
| 1209 | return(ret); | ||
| 1210 | } | ||
| 1211 | #endif /* NETWARE */ | ||
diff --git a/src/lib/libcrypto/threads/netware.bat b/src/lib/libcrypto/threads/netware.bat new file mode 100644 index 0000000000..0b3eca3caf --- /dev/null +++ b/src/lib/libcrypto/threads/netware.bat | |||
| @@ -0,0 +1,79 @@ | |||
| 1 | @echo off | ||
| 2 | rem batch file to build multi-thread test ( mttest.nlm ) | ||
| 3 | |||
| 4 | rem command line arguments: | ||
| 5 | rem debug => build using debug settings | ||
| 6 | |||
| 7 | rem | ||
| 8 | rem After building, copy mttest.nlm to the server and run it, you'll probably | ||
| 9 | rem want to redirect stdout and stderr. An example command line would be | ||
| 10 | rem "mttest.nlm -thread 20 -loops 10 -CAfile \openssl\apps\server.pem >mttest.out 2>mttest.err" | ||
| 11 | rem | ||
| 12 | |||
| 13 | del mttest.nlm | ||
| 14 | |||
| 15 | set BLD_DEBUG= | ||
| 16 | set CFLAGS= | ||
| 17 | set LFLAGS= | ||
| 18 | set LIBS= | ||
| 19 | |||
| 20 | if "%1" == "DEBUG" set BLD_DEBUG=YES | ||
| 21 | if "%1" == "debug" set BLD_DEBUG=YES | ||
| 22 | |||
| 23 | if "%MWCIncludes%" == "" goto inc_error | ||
| 24 | if "%PRELUDE%" == "" goto prelude_error | ||
| 25 | if "%IMPORTS%" == "" goto imports_error | ||
| 26 | |||
| 27 | set CFLAGS=-c -I..\..\outinc_nw -nosyspath -DOPENSSL_SYS_NETWARE -opt off -g -sym internal -maxerrors 20 | ||
| 28 | |||
| 29 | if "%BLD_DEBUG%" == "YES" set LIBS=..\..\out_nw.dbg\ssl.lib ..\..\out_nw.dbg\crypto.lib | ||
| 30 | if "%BLD_DEBUG%" == "" set LIBS=..\..\out_nw\ssl.lib ..\..\out_nw\crypto.lib | ||
| 31 | |||
| 32 | set LFLAGS=-msgstyle gcc -zerobss -stacksize 32768 -nostdlib -sym internal | ||
| 33 | |||
| 34 | rem generate command file for metrowerks | ||
| 35 | echo. | ||
| 36 | echo Generating Metrowerks command file: mttest.def | ||
| 37 | echo # dynamically generated command file for metrowerks build > mttest.def | ||
| 38 | echo IMPORT @%IMPORTS%\clib.imp >> mttest.def | ||
| 39 | echo IMPORT @%IMPORTS%\threads.imp >> mttest.def | ||
| 40 | echo IMPORT @%IMPORTS%\ws2nlm.imp >> mttest.def | ||
| 41 | echo IMPORT GetProcessSwitchCount >> mttest.def | ||
| 42 | echo MODULE clib >> mttest.def | ||
| 43 | |||
| 44 | rem compile | ||
| 45 | echo. | ||
| 46 | echo Compiling mttest.c | ||
| 47 | mwccnlm.exe mttest.c %CFLAGS% | ||
| 48 | if errorlevel 1 goto end | ||
| 49 | |||
| 50 | rem link | ||
| 51 | echo. | ||
| 52 | echo Linking mttest.nlm | ||
| 53 | mwldnlm.exe %LFLAGS% -screenname mttest -commandfile mttest.def mttest.o "%PRELUDE%" %LIBS% -o mttest.nlm | ||
| 54 | if errorlevel 1 goto end | ||
| 55 | |||
| 56 | goto end | ||
| 57 | |||
| 58 | :inc_error | ||
| 59 | echo. | ||
| 60 | echo Environment variable MWCIncludes is not set - see install.nw | ||
| 61 | goto end | ||
| 62 | |||
| 63 | :prelude_error | ||
| 64 | echo. | ||
| 65 | echo Environment variable PRELUDE is not set - see install.nw | ||
| 66 | goto end | ||
| 67 | |||
| 68 | :imports_error | ||
| 69 | echo. | ||
| 70 | echo Environment variable IMPORTS is not set - see install.nw | ||
| 71 | goto end | ||
| 72 | |||
| 73 | |||
| 74 | :end | ||
| 75 | set BLD_DEBUG= | ||
| 76 | set CFLAGS= | ||
| 77 | set LFLAGS= | ||
| 78 | set LIBS= | ||
| 79 | |||
diff --git a/src/lib/libcrypto/threads/th-lock.c b/src/lib/libcrypto/threads/th-lock.c index 14aae5f912..a6a79b9f45 100644 --- a/src/lib/libcrypto/threads/th-lock.c +++ b/src/lib/libcrypto/threads/th-lock.c | |||
| @@ -80,7 +80,7 @@ | |||
| 80 | #include <openssl/lhash.h> | 80 | #include <openssl/lhash.h> |
| 81 | #include <openssl/crypto.h> | 81 | #include <openssl/crypto.h> |
| 82 | #include <openssl/buffer.h> | 82 | #include <openssl/buffer.h> |
| 83 | #include "../../e_os.h" | 83 | #include <openssl/e_os.h> |
| 84 | #include <openssl/x509.h> | 84 | #include <openssl/x509.h> |
| 85 | #include <openssl/ssl.h> | 85 | #include <openssl/ssl.h> |
| 86 | #include <openssl/err.h> | 86 | #include <openssl/err.h> |
