aboutsummaryrefslogtreecommitdiff
path: root/crypto/openssl/crypto/threads/mttest.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/openssl/crypto/threads/mttest.c')
-rw-r--r--crypto/openssl/crypto/threads/mttest.c115
1 files changed, 115 insertions, 0 deletions
diff --git a/crypto/openssl/crypto/threads/mttest.c b/crypto/openssl/crypto/threads/mttest.c
index 7588966cb219..f6f3df4b6aa8 100644
--- a/crypto/openssl/crypto/threads/mttest.c
+++ b/crypto/openssl/crypto/threads/mttest.c
@@ -77,6 +77,12 @@
#ifdef PTHREADS
#include <pthread.h>
#endif
+#ifdef OPENSSL_SYS_NETWARE
+#if !defined __int64
+# define __int64 long long
+#endif
+#include <nwmpk.h>
+#endif
#include <openssl/lhash.h>
#include <openssl/crypto.h>
#include <openssl/buffer.h>
@@ -86,8 +92,18 @@
#include <openssl/err.h>
#include <openssl/rand.h>
+#ifdef OPENSSL_NO_FP_API
+#define APPS_WIN16
+#include "../buffer/bss_file.c"
+#endif
+
+#ifdef OPENSSL_SYS_NETWARE
+#define TEST_SERVER_CERT "/openssl/apps/server.pem"
+#define TEST_CLIENT_CERT "/openssl/apps/client.pem"
+#else
#define TEST_SERVER_CERT "../../apps/server.pem"
#define TEST_CLIENT_CERT "../../apps/client.pem"
+#endif
#define MAX_THREAD_NUMBER 100
@@ -100,10 +116,18 @@ void irix_locking_callback(int mode,int type,char *file,int line);
void solaris_locking_callback(int mode,int type,char *file,int line);
void win32_locking_callback(int mode,int type,char *file,int line);
void pthreads_locking_callback(int mode,int type,char *file,int line);
+void netware_locking_callback(int mode,int type,char *file,int line);
unsigned long irix_thread_id(void );
unsigned long solaris_thread_id(void );
unsigned long pthreads_thread_id(void );
+unsigned long netware_thread_id(void );
+
+#if defined(OPENSSL_SYS_NETWARE)
+static MPKMutex *lock_cs;
+static MPKSema ThreadSem;
+static long *lock_count;
+#endif
BIO *bio_err=NULL;
BIO *bio_stdout=NULL;
@@ -384,6 +408,9 @@ int ndoit(SSL_CTX *ssl_ctx[2])
SSL_free((SSL *)ctx[2]);
SSL_free((SSL *)ctx[3]);
}
+# ifdef OPENSSL_SYS_NETWARE
+ MPKSemaphoreSignal(ThreadSem);
+# endif
return(0);
}
@@ -627,6 +654,9 @@ int doit(char *ctx[4])
}
if ((done & S_DONE) && (done & C_DONE)) break;
+# if defined(OPENSSL_SYS_NETWARE)
+ ThreadSwitchWithDelay();
+# endif
}
SSL_set_shutdown(c_ssl,SSL_SENT_SHUTDOWN|SSL_RECEIVED_SHUTDOWN);
@@ -1094,3 +1124,88 @@ unsigned long pthreads_thread_id(void)
+#ifdef OPENSSL_SYS_NETWARE
+
+void thread_setup(void)
+{
+ int i;
+
+ lock_cs=OPENSSL_malloc(CRYPTO_num_locks() * sizeof(MPKMutex));
+ lock_count=OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long));
+ for (i=0; i<CRYPTO_num_locks(); i++)
+ {
+ lock_count[i]=0;
+ lock_cs[i]=MPKMutexAlloc("OpenSSL mutex");
+ }
+
+ ThreadSem = MPKSemaphoreAlloc("OpenSSL mttest semaphore", 0 );
+
+ CRYPTO_set_id_callback((unsigned long (*)())netware_thread_id);
+ CRYPTO_set_locking_callback((void (*)())netware_locking_callback);
+}
+
+void thread_cleanup(void)
+{
+ int i;
+
+ CRYPTO_set_locking_callback(NULL);
+
+ fprintf(stdout,"thread_cleanup\n");
+
+ for (i=0; i<CRYPTO_num_locks(); i++)
+ {
+ MPKMutexFree(lock_cs[i]);
+ fprintf(stdout,"%8ld:%s\n",lock_count[i],CRYPTO_get_lock_name(i));
+ }
+ OPENSSL_free(lock_cs);
+ OPENSSL_free(lock_count);
+
+ MPKSemaphoreFree(ThreadSem);
+
+ fprintf(stdout,"done cleanup\n");
+}
+
+void netware_locking_callback(int mode, int type, char *file, int line)
+{
+ if (mode & CRYPTO_LOCK)
+ {
+ MPKMutexLock(lock_cs[type]);
+ lock_count[type]++;
+ }
+ else
+ MPKMutexUnlock(lock_cs[type]);
+}
+
+void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx)
+{
+ SSL_CTX *ssl_ctx[2];
+ int i;
+ ssl_ctx[0]=s_ctx;
+ ssl_ctx[1]=c_ctx;
+
+ for (i=0; i<thread_number; i++)
+ {
+ BeginThread( (void(*)(void*))ndoit, NULL, THREAD_STACK_SIZE,
+ (void*)ssl_ctx);
+ ThreadSwitchWithDelay();
+ }
+
+ printf("reaping\n");
+
+ /* loop until all threads have signaled the semaphore */
+ for (i=0; i<thread_number; i++)
+ {
+ MPKSemaphoreWait(ThreadSem);
+ }
+ printf("netware threads done (%d,%d)\n",
+ s_ctx->references,c_ctx->references);
+}
+
+unsigned long netware_thread_id(void)
+{
+ unsigned long ret;
+
+ ret=(unsigned long)GetThreadID();
+ return(ret);
+}
+#endif /* NETWARE */