summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/threads
diff options
context:
space:
mode:
authordjm <>2008-09-06 12:17:54 +0000
committerdjm <>2008-09-06 12:17:54 +0000
commit38ce604e3cc97706b876b0525ddff0121115456d (patch)
tree7ccc28afe1789ea3dbedf72365f955d5b8e105b5 /src/lib/libcrypto/threads
parent12867252827c8efaa8ddd1fa3b3d6e321e2bcdef (diff)
downloadopenbsd-38ce604e3cc97706b876b0525ddff0121115456d.tar.gz
openbsd-38ce604e3cc97706b876b0525ddff0121115456d.tar.bz2
openbsd-38ce604e3cc97706b876b0525ddff0121115456d.zip
resolve conflicts
Diffstat (limited to 'src/lib/libcrypto/threads')
-rw-r--r--src/lib/libcrypto/threads/mttest.c115
-rw-r--r--src/lib/libcrypto/threads/th-lock.c2
2 files changed, 116 insertions, 1 deletions
diff --git a/src/lib/libcrypto/threads/mttest.c b/src/lib/libcrypto/threads/mttest.c
index 7588966cb2..f6f3df4b6a 100644
--- a/src/lib/libcrypto/threads/mttest.c
+++ b/src/lib/libcrypto/threads/mttest.c
@@ -77,6 +77,12 @@
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
80#include <openssl/lhash.h> 86#include <openssl/lhash.h>
81#include <openssl/crypto.h> 87#include <openssl/crypto.h>
82#include <openssl/buffer.h> 88#include <openssl/buffer.h>
@@ -86,8 +92,18 @@
86#include <openssl/err.h> 92#include <openssl/err.h>
87#include <openssl/rand.h> 93#include <openssl/rand.h>
88 94
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
89#define TEST_SERVER_CERT "../../apps/server.pem" 104#define TEST_SERVER_CERT "../../apps/server.pem"
90#define TEST_CLIENT_CERT "../../apps/client.pem" 105#define TEST_CLIENT_CERT "../../apps/client.pem"
106#endif
91 107
92#define MAX_THREAD_NUMBER 100 108#define MAX_THREAD_NUMBER 100
93 109
@@ -100,10 +116,18 @@ void irix_locking_callback(int mode,int type,char *file,int line);
100void solaris_locking_callback(int mode,int type,char *file,int line); 116void solaris_locking_callback(int mode,int type,char *file,int line);
101void win32_locking_callback(int mode,int type,char *file,int line); 117void win32_locking_callback(int mode,int type,char *file,int line);
102void pthreads_locking_callback(int mode,int type,char *file,int line); 118void pthreads_locking_callback(int mode,int type,char *file,int line);
119void netware_locking_callback(int mode,int type,char *file,int line);
103 120
104unsigned long irix_thread_id(void ); 121unsigned long irix_thread_id(void );
105unsigned long solaris_thread_id(void ); 122unsigned long solaris_thread_id(void );
106unsigned long pthreads_thread_id(void ); 123unsigned 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
107 131
108BIO *bio_err=NULL; 132BIO *bio_err=NULL;
109BIO *bio_stdout=NULL; 133BIO *bio_stdout=NULL;
@@ -384,6 +408,9 @@ int ndoit(SSL_CTX *ssl_ctx[2])
384 SSL_free((SSL *)ctx[2]); 408 SSL_free((SSL *)ctx[2]);
385 SSL_free((SSL *)ctx[3]); 409 SSL_free((SSL *)ctx[3]);
386 } 410 }
411# ifdef OPENSSL_SYS_NETWARE
412 MPKSemaphoreSignal(ThreadSem);
413# endif
387 return(0); 414 return(0);
388 } 415 }
389 416
@@ -627,6 +654,9 @@ int doit(char *ctx[4])
627 } 654 }
628 655
629 if ((done & S_DONE) && (done & C_DONE)) break; 656 if ((done & S_DONE) && (done & C_DONE)) break;
657# if defined(OPENSSL_SYS_NETWARE)
658 ThreadSwitchWithDelay();
659# endif
630 } 660 }
631 661
632 SSL_set_shutdown(c_ssl,SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN); 662 SSL_set_shutdown(c_ssl,SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
@@ -1094,3 +1124,88 @@ unsigned long pthreads_thread_id(void)
1094 1124
1095 1125
1096 1126
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/th-lock.c b/src/lib/libcrypto/threads/th-lock.c
index a6a79b9f45..14aae5f912 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 <openssl/e_os.h> 83#include "../../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>