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.c115
-rw-r--r--src/lib/libcrypto/threads/netware.bat79
-rw-r--r--src/lib/libcrypto/threads/th-lock.c2
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);
116void solaris_locking_callback(int mode,int type,char *file,int line); 100void solaris_locking_callback(int mode,int type,char *file,int line);
117void win32_locking_callback(int mode,int type,char *file,int line); 101void win32_locking_callback(int mode,int type,char *file,int line);
118void pthreads_locking_callback(int mode,int type,char *file,int line); 102void pthreads_locking_callback(int mode,int type,char *file,int line);
119void netware_locking_callback(int mode,int type,char *file,int line);
120 103
121unsigned long irix_thread_id(void ); 104unsigned long irix_thread_id(void );
122unsigned long solaris_thread_id(void ); 105unsigned long solaris_thread_id(void );
123unsigned long pthreads_thread_id(void ); 106unsigned long pthreads_thread_id(void );
124unsigned long netware_thread_id(void );
125
126#if defined(OPENSSL_SYS_NETWARE)
127static MPKMutex *lock_cs;
128static MPKSema ThreadSem;
129static long *lock_count;
130#endif
131 107
132BIO *bio_err=NULL; 108BIO *bio_err=NULL;
133BIO *bio_stdout=NULL; 109BIO *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
1129void 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
1147void 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
1168void 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
1179void 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
1204unsigned 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
2rem batch file to build multi-thread test ( mttest.nlm )
3
4rem command line arguments:
5rem debug => build using debug settings
6
7rem
8rem After building, copy mttest.nlm to the server and run it, you'll probably
9rem want to redirect stdout and stderr. An example command line would be
10rem "mttest.nlm -thread 20 -loops 10 -CAfile \openssl\apps\server.pem >mttest.out 2>mttest.err"
11rem
12
13del mttest.nlm
14
15set BLD_DEBUG=
16set CFLAGS=
17set LFLAGS=
18set LIBS=
19
20if "%1" == "DEBUG" set BLD_DEBUG=YES
21if "%1" == "debug" set BLD_DEBUG=YES
22
23if "%MWCIncludes%" == "" goto inc_error
24if "%PRELUDE%" == "" goto prelude_error
25if "%IMPORTS%" == "" goto imports_error
26
27set CFLAGS=-c -I..\..\outinc_nw -nosyspath -DOPENSSL_SYS_NETWARE -opt off -g -sym internal -maxerrors 20
28
29if "%BLD_DEBUG%" == "YES" set LIBS=..\..\out_nw.dbg\ssl.lib ..\..\out_nw.dbg\crypto.lib
30if "%BLD_DEBUG%" == "" set LIBS=..\..\out_nw\ssl.lib ..\..\out_nw\crypto.lib
31
32set LFLAGS=-msgstyle gcc -zerobss -stacksize 32768 -nostdlib -sym internal
33
34rem generate command file for metrowerks
35echo.
36echo Generating Metrowerks command file: mttest.def
37echo # dynamically generated command file for metrowerks build > mttest.def
38echo IMPORT @%IMPORTS%\clib.imp >> mttest.def
39echo IMPORT @%IMPORTS%\threads.imp >> mttest.def
40echo IMPORT @%IMPORTS%\ws2nlm.imp >> mttest.def
41echo IMPORT GetProcessSwitchCount >> mttest.def
42echo MODULE clib >> mttest.def
43
44rem compile
45echo.
46echo Compiling mttest.c
47mwccnlm.exe mttest.c %CFLAGS%
48if errorlevel 1 goto end
49
50rem link
51echo.
52echo Linking mttest.nlm
53mwldnlm.exe %LFLAGS% -screenname mttest -commandfile mttest.def mttest.o "%PRELUDE%" %LIBS% -o mttest.nlm
54if errorlevel 1 goto end
55
56goto end
57
58:inc_error
59echo.
60echo Environment variable MWCIncludes is not set - see install.nw
61goto end
62
63:prelude_error
64echo.
65echo Environment variable PRELUDE is not set - see install.nw
66goto end
67
68:imports_error
69echo.
70echo Environment variable IMPORTS is not set - see install.nw
71goto end
72
73
74:end
75set BLD_DEBUG=
76set CFLAGS=
77set LFLAGS=
78set 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>