From 2d2d31394a710cfe854e3dd7f862613a6b45fcc4 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Fri, 25 Feb 2000 23:16:56 +0000 Subject: Update the two threads modules to conform to our recommendations (use CRYPTO_num_locks() instead of CRYPTO_NUM_LOCKS!), and correct all the inconsistencies with the rest of OpenSSL. At least, this compiles nicely on Linux using PTHREADS. I've done no other tests so far. --- crypto/threads/mttest.c | 101 +++++++++++++++++++++++++++++------------------ crypto/threads/th-lock.c | 53 +++++++++++++++++-------- 2 files changed, 98 insertions(+), 56 deletions(-) (limited to 'crypto/threads') diff --git a/crypto/threads/mttest.c b/crypto/threads/mttest.c index 3e4d231f25..40c1cfc6c2 100644 --- a/crypto/threads/mttest.c +++ b/crypto/threads/mttest.c @@ -74,26 +74,28 @@ #include #include #endif +#ifdef PTHREADS +#include +#endif #include #include #include -#include "../e_os.h" +#include "../../e_os.h" #include #include #include #ifdef NO_FP_API #define APPS_WIN16 -#include "../crypto/buffer/bss_file.c" +#include "../buffer/bss_file.c" #endif -#define TEST_SERVER_CERT "../apps/server.pem" -#define TEST_CLIENT_CERT "../apps/client.pem" +#define TEST_SERVER_CERT "../../apps/server.pem" +#define TEST_CLIENT_CERT "../../apps/client.pem" #define MAX_THREAD_NUMBER 100 -int MS_CALLBACK verify_callback(int ok, X509 *xs, X509 *xi, int depth, - int error,char *arg); +int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *xs); void thread_setup(void); void thread_cleanup(void); void do_threads(SSL_CTX *s_ctx,SSL_CTX *c_ctx); @@ -652,18 +654,22 @@ err: return(0); } -int MS_CALLBACK verify_callback(int ok, X509 *xs, X509 *xi, int depth, - int error, char *arg) +int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx) { - char buf[256]; + char *s, buf[256]; if (verbose) { - X509_NAME_oneline(X509_get_subject_name(xs),buf,256); - if (ok) - fprintf(stderr,"depth=%d %s\n",depth,buf); - else - fprintf(stderr,"depth=%d error=%d %s\n",depth,error,buf); + if (s != NULL) + { + s=X509_NAME_oneline(X509_get_subject_name(ctx->current_cert),buf,256); + if (ok) + fprintf(stderr,"depth=%d %s\n", + ctx->error_depth,buf); + else + fprintf(stderr,"depth=%d error=%d %s\n", + ctx->error_depth,ctx->error,buf); + } } return(ok); } @@ -672,13 +678,14 @@ int MS_CALLBACK verify_callback(int ok, X509 *xs, X509 *xi, int depth, #ifdef WIN32 -static HANDLE lock_cs[CRYPTO_NUM_LOCKS]; +static HANDLE *lock_cs; void thread_setup(void) { int i; - for (i=0; ireferences,c_ctx->references); + s_ctx->references,c_ctx->references); } unsigned long pthreads_thread_id(void) diff --git a/crypto/threads/th-lock.c b/crypto/threads/th-lock.c index 7a6b091669..3ee978060c 100644 --- a/crypto/threads/th-lock.c +++ b/crypto/threads/th-lock.c @@ -74,6 +74,9 @@ #include #include #endif +#ifdef PTHREADS +#include +#endif #include #include #include @@ -82,7 +85,7 @@ #include #include -int CRYPTO_thread_setup(void); +void CRYPTO_thread_setup(void); void CRYPTO_thread_cleanup(void); static void irix_locking_callback(int mode,int type,char *file,int line); @@ -104,13 +107,14 @@ static unsigned long pthreads_thread_id(void ); #ifdef WIN32 -static HANDLE lock_cs[CRYPTO_NUM_LOCKS]; +static HANDLE *lock_cs; -int CRYPTO_thread_setup(void) +void CRYPTO_thread_setup(void) { int i; - for (i=0; i