#include <ulocks.h>
#include <sys/prctl.h>
#endif
+#ifdef PTHREADS
+#include <pthread.h>
+#endif
#include <openssl/lhash.h>
#include <openssl/crypto.h>
#include <openssl/buffer.h>
-#include "../e_os.h"
+#include "../../e_os.h"
#include <openssl/x509.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#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);
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);
}
#ifdef WIN32
-static HANDLE lock_cs[CRYPTO_NUM_LOCKS];
+static HANDLE *lock_cs;
void thread_setup(void)
{
int i;
- for (i=0; i<CRYPTO_NUM_LOCKS; i++)
+ lock_cs=Malloc(CRYPTO_num_locks() * sizeof(HANDLE));
+ for (i=0; i<CRYPTO_num_locks(); i++)
{
lock_cs[i]=CreateMutex(NULL,FALSE,NULL);
}
int i;
CRYPTO_set_locking_callback(NULL);
- for (i=0; i<CRYPTO_NUM_LOCKS; i++)
+ for (i=0; i<CRYPTO_num_locks(); i++)
CloseHandle(lock_cs[i]);
+ Free(lock_cs);
}
void win32_locking_callback(int mode, int type, char *file, int line)
#ifdef SOLARIS
-static mutex_t lock_cs[CRYPTO_NUM_LOCKS];
-/*static rwlock_t lock_cs[CRYPTO_NUM_LOCKS]; */
-static long lock_count[CRYPTO_NUM_LOCKS];
+static mutex_t *lock_cs;
+/*static rwlock_t *lock_cs; */
+static long *lock_count;
void thread_setup(void)
{
int i;
- for (i=0; i<CRYPTO_NUM_LOCKS; i++)
+ lock_cs=Malloc(CRYPTO_num_locks() * sizeof(mutex_t));
+ lock_count=Malloc(CRYPTO_num_locks() * sizeof(long));
+ for (i=0; i<CRYPTO_num_locks(); i++)
{
lock_count[i]=0;
/* rwlock_init(&(lock_cs[i]),USYNC_THREAD,NULL); */
int i;
CRYPTO_set_locking_callback(NULL);
-fprintf(stderr,"cleanup\n");
- for (i=0; i<CRYPTO_NUM_LOCKS; i++)
+
+ fprintf(stderr,"cleanup\n");
+
+ for (i=0; i<CRYPTO_num_locks(); i++)
{
/* rwlock_destroy(&(lock_cs[i])); */
mutex_destroy(&(lock_cs[i]));
fprintf(stderr,"%8ld:%s\n",lock_count[i],CRYPTO_get_lock_name(i));
}
-fprintf(stderr,"done cleanup\n");
+ Free(lock_cs);
+ Free(lock_count);
+
+ fprintf(stderr,"done cleanup\n");
+
}
void solaris_locking_callback(int mode, int type, char *file, int line)
{
#ifdef undef
-fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n",
- CRYPTO_thread_id(),
- (mode&CRYPTO_LOCK)?"l":"u",
- (type&CRYPTO_READ)?"r":"w",file,line);
+ fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n",
+ CRYPTO_thread_id(),
+ (mode&CRYPTO_LOCK)?"l":"u",
+ (type&CRYPTO_READ)?"r":"w",file,line);
#endif
-/*
-if (CRYPTO_LOCK_SSL_CERT == type)
+ /*
+ if (CRYPTO_LOCK_SSL_CERT == type)
fprintf(stderr,"(t,m,f,l) %ld %d %s %d\n",
CRYPTO_thread_id(),
mode,file,line);
-*/
+ */
if (mode & CRYPTO_LOCK)
{
/* if (mode & CRYPTO_READ)
static usptr_t *arena;
-static usema_t *lock_cs[CRYPTO_NUM_LOCKS];
+static usema_t **lock_cs;
void thread_setup(void)
{
arena=usinit(filename);
unlink(filename);
- for (i=0; i<CRYPTO_NUM_LOCKS; i++)
+ lock_cs=Malloc(CRYPTO_num_locks() * sizeof(usema_t *));
+ for (i=0; i<CRYPTO_num_locks(); i++)
{
lock_cs[i]=usnewsema(arena,1);
}
int i;
CRYPTO_set_locking_callback(NULL);
- for (i=0; i<CRYPTO_NUM_LOCKS; i++)
+ for (i=0; i<CRYPTO_num_locks(); i++)
{
char buf[10];
usdumpsema(lock_cs[i],stdout,buf);
usfreesema(lock_cs[i],arena);
}
+ Free(lock_cs);
}
void irix_locking_callback(int mode, int type, char *file, int line)
#ifdef PTHREADS
-static pthread_mutex_t lock_cs[CRYPTO_NUM_LOCKS];
-static long lock_count[CRYPTO_NUM_LOCKS];
+static pthread_mutex_t *lock_cs;
+static long *lock_count;
void thread_setup(void)
{
int i;
- for (i=0; i<CRYPTO_NUM_LOCKS; i++)
+ lock_cs=Malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t));
+ lock_count=Malloc(CRYPTO_num_locks() * sizeof(long));
+ for (i=0; i<CRYPTO_num_locks(); i++)
{
lock_count[i]=0;
pthread_mutex_init(&(lock_cs[i]),NULL);
CRYPTO_set_locking_callback(NULL);
fprintf(stderr,"cleanup\n");
- for (i=0; i<CRYPTO_NUM_LOCKS; i++)
+ for (i=0; i<CRYPTO_num_locks(); i++)
{
pthread_mutex_destroy(&(lock_cs[i]));
fprintf(stderr,"%8ld:%s\n",lock_count[i],
CRYPTO_get_lock_name(i));
}
+ Free(lock_cs);
+ Free(lock_count);
+
fprintf(stderr,"done cleanup\n");
}
}
printf("pthreads threads done (%d,%d)\n",
- s_ctx->references,c_ctx->references);
+ s_ctx->references,c_ctx->references);
}
unsigned long pthreads_thread_id(void)
#include <ulocks.h>
#include <sys/prctl.h>
#endif
+#ifdef PTHREADS
+#include <pthread.h>
+#endif
#include <openssl/lhash.h>
#include <openssl/crypto.h>
#include <openssl/buffer.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
-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);
#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<CRYPTO_NUM_LOCKS; i++)
+ lock_cs=Malloc(CRYPTO_num_locks() * sizeof(HANDLE));
+ for (i=0; i<CRYPTO_num_locks(); i++)
{
lock_cs[i]=CreateMutex(NULL,FALSE,NULL);
}
int i;
CRYPTO_set_locking_callback(NULL);
- for (i=0; i<CRYPTO_NUM_LOCKS; i++)
+ for (i=0; i<CRYPTO_num_locks(); i++)
CloseHandle(lock_cs[i]);
+ Free(lock_cs);
}
void win32_locking_callback(int mode, int type, char *file, int line)
#define USE_MUTEX
-static mutex_t lock_cs[CRYPTO_NUM_LOCKS];
#ifdef USE_MUTEX
-static long lock_count[CRYPTO_NUM_LOCKS];
+static mutex_t *lock_cs;
#else
-static rwlock_t lock_cs[CRYPTO_NUM_LOCKS];
+static rwlock_t *lock_cs;
#endif
+static long *lock_count;
void CRYPTO_thread_setup(void)
{
int i;
- for (i=0; i<CRYPTO_NUM_LOCKS; i++)
+#ifdef USE_MUTEX
+ lock_cs=Malloc(CRYPTO_num_locks() * sizeof(mutex_t));
+#else
+ lock_cs=Malloc(CRYPTO_num_locks() * sizeof(rwlock_t));
+#endif
+ lock_count=Malloc(CRYPTO_num_locks() * sizeof(long));
+ for (i=0; i<CRYPTO_num_locks(); i++)
{
lock_count[i]=0;
#ifdef USE_MUTEX
int i;
CRYPTO_set_locking_callback(NULL);
- for (i=0; i<CRYPTO_NUM_LOCKS; i++)
+ for (i=0; i<CRYPTO_num_locks(); i++)
{
#ifdef USE_MUTEX
mutex_destroy(&(lock_cs[i]));
rwlock_destroy(&(lock_cs[i]));
#endif
}
+ Free(lock_cs);
+ Free(lock_count);
}
void solaris_locking_callback(int mode, int type, char *file, int line)
/* I don't think this works..... */
static usptr_t *arena;
-static usema_t *lock_cs[CRYPTO_NUM_LOCKS];
+static usema_t **lock_cs;
void CRYPTO_thread_setup(void)
{
arena=usinit(filename);
unlink(filename);
- for (i=0; i<CRYPTO_NUM_LOCKS; i++)
+ lock_cs=Malloc(CRYPTO_num_locks() * sizeof(usema_t *));
+ for (i=0; i<CRYPTO_num_locks(); i++)
{
lock_cs[i]=usnewsema(arena,1);
}
int i;
CRYPTO_set_locking_callback(NULL);
- for (i=0; i<CRYPTO_NUM_LOCKS; i++)
+ for (i=0; i<CRYPTO_num_locks(); i++)
{
char buf[10];
usdumpsema(lock_cs[i],stdout,buf);
usfreesema(lock_cs[i],arena);
}
+ Free(lock_cs);
}
void irix_locking_callback(int mode, int type, char *file, int line)
/* Linux and a few others */
#ifdef PTHREADS
-static pthread_mutex_t lock_cs[CRYPTO_NUM_LOCKS];
-static long lock_count[CRYPTO_NUM_LOCKS];
+static pthread_mutex_t *lock_cs;
+static long *lock_count;
void CRYPTO_thread_setup(void)
{
int i;
- for (i=0; i<CRYPTO_NUM_LOCKS; i++)
+ lock_cs=Malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t));
+ lock_count=Malloc(CRYPTO_num_locks() * sizeof(long));
+ for (i=0; i<CRYPTO_num_locks(); i++)
{
lock_count[i]=0;
pthread_mutex_init(&(lock_cs[i]),NULL);
int i;
CRYPTO_set_locking_callback(NULL);
- for (i=0; i<CRYPTO_NUM_LOCKS; i++)
+ for (i=0; i<CRYPTO_num_locks(); i++)
{
pthread_mutex_destroy(&(lock_cs[i]));
}
+ Free(lock_cs);
+ Free(lock_count);
}
void pthreads_locking_callback(int mode, int type, char *file,