diff options
author | Richard Levitte <levitte@openssl.org> | 2003-11-28 13:10:58 +0000 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2003-11-28 13:10:58 +0000 |
commit | 4d8743f490a5f96fa26d41985ee12cb6b9815a4c (patch) | |
tree | 9668a30c8c9bcc3347eddb5b553d8f1c6ccc8524 /crypto/threads/mttest.c | |
parent | 4c8b4f9d03fb5db99fa22b235369b96039f60706 (diff) |
Netware-specific changes,
PR: 780
Submitted by: Verdon Walker <VWalker@novell.com>
Reviewed by: Richard Levitte
Diffstat (limited to 'crypto/threads/mttest.c')
-rw-r--r-- | crypto/threads/mttest.c | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/crypto/threads/mttest.c b/crypto/threads/mttest.c index 54d598565d..d0e088218b 100644 --- a/crypto/threads/mttest.c +++ b/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; @@ -383,6 +407,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); } @@ -626,6 +653,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); @@ -1093,3 +1123,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 */ |