diff --git a/src/main/init.c b/src/main/init.c index 4c3492f11..f1977389f 100644 --- a/src/main/init.c +++ b/src/main/init.c @@ -32,12 +32,8 @@ int libre_init(void) goto out; out: - if (err) { + if (err) net_sock_close(); -#ifdef USE_OPENSSL - openssl_close(); -#endif - } return err; } @@ -50,7 +46,4 @@ void libre_close(void) { (void)fd_setsize(0); net_sock_close(); -#ifdef USE_OPENSSL - openssl_close(); -#endif } diff --git a/src/main/openssl.c b/src/main/openssl.c index 2b8e163b5..47a8a7d72 100644 --- a/src/main/openssl.c +++ b/src/main/openssl.c @@ -18,84 +18,6 @@ #include "main.h" -#if defined (HAVE_PTHREAD) && (OPENSSL_VERSION_NUMBER < 0x10100000L) - - -static pthread_mutex_t *lockv; - - -static inline unsigned long threadid(void) -{ -#if defined (DARWIN) || defined (FREEBSD) || defined (OPENBSD) || \ - defined (NETBSD) || defined (DRAGONFLY) - return (unsigned long)(void *)pthread_self(); -#else - return (unsigned long)pthread_self(); -#endif -} - - -static void threadid_handler(CRYPTO_THREADID *id) -{ - CRYPTO_THREADID_set_numeric(id, threadid()); -} - - -static void locking_handler(int mode, int type, const char *file, int line) -{ - (void)file; - (void)line; - - if (mode & CRYPTO_LOCK) - (void)pthread_mutex_lock(&lockv[type]); - else - (void)pthread_mutex_unlock(&lockv[type]); -} - - -#endif - - -#if OPENSSL_VERSION_NUMBER < 0x10100000L -static struct CRYPTO_dynlock_value *dynlock_create_handler(const char *file, - int line) -{ - struct lock *lock; - (void)file; - (void)line; - - if (lock_alloc(&lock)) - return NULL; - - return (struct CRYPTO_dynlock_value *)lock; -} - - -static void dynlock_lock_handler(int mode, struct CRYPTO_dynlock_value *l, - const char *file, int line) -{ - struct lock *lock = (struct lock *)l; - (void)file; - (void)line; - - if (mode & CRYPTO_LOCK) - lock_write_get(lock); - else - lock_rel(lock); -} - - -static void dynlock_destroy_handler(struct CRYPTO_dynlock_value *l, - const char *file, int line) -{ - (void)file; - (void)line; - - mem_deref(l); -} -#endif - - #ifdef SIGPIPE static void sigpipe_handler(int x) { @@ -108,56 +30,14 @@ static void sigpipe_handler(int x) int openssl_init(void) { int err; -#if defined (HAVE_PTHREAD) && (OPENSSL_VERSION_NUMBER < 0x10100000L) - int i; - - lockv = mem_zalloc(sizeof(pthread_mutex_t) * CRYPTO_num_locks(), NULL); - if (!lockv) - return ENOMEM; - - for (i=0; i= 0x10100000L err = OPENSSL_init_ssl(OPENSSL_INIT_SSL_DEFAULT, NULL); if (!err) return !err; -#else - SSL_library_init(); - SSL_load_error_strings(); -#endif return 0; } - - -void openssl_close(void) -{ -#if OPENSSL_VERSION_NUMBER < 0x10100000L - ERR_free_strings(); -#endif -#if defined (HAVE_PTHREAD) && (OPENSSL_VERSION_NUMBER < 0x10100000L) - lockv = mem_deref(lockv); -#endif -}