summaryrefslogtreecommitdiff
path: root/accel-pppd/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'accel-pppd/main.c')
-rw-r--r--accel-pppd/main.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/accel-pppd/main.c b/accel-pppd/main.c
index 14180605..491e07db 100644
--- a/accel-pppd/main.c
+++ b/accel-pppd/main.c
@@ -9,10 +9,15 @@
#include <limits.h>
#include <malloc.h>
#include <dirent.h>
+#include <pthread.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/resource.h>
+#ifdef CRYPTO_OPENSSL
+#include <openssl/ssl.h>
+#endif
+
#include "triton/triton.h"
#include "memdebug.h"
@@ -29,6 +34,40 @@ static char *conf_file;
static char *conf_dump;
static sigset_t orig_set;
+#ifdef CRYPTO_OPENSSL
+static pthread_mutex_t *ssl_lock_cs;
+
+static unsigned long ssl_thread_id(void)
+{
+ return (unsigned long)pthread_self();
+}
+
+static void ssl_lock(int mode, int type, const char *file, int line)
+{
+ if (mode & CRYPTO_LOCK)
+ pthread_mutex_lock(&ssl_lock_cs[type]);
+ else
+ pthread_mutex_unlock(&ssl_lock_cs[type]);
+}
+
+static void openssl_init(void)
+{
+ int i;
+
+ SSL_library_init();
+ SSL_load_error_strings();
+ OpenSSL_add_all_algorithms();
+
+ ssl_lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t));
+
+ for (i = 0; i < CRYPTO_num_locks(); i++)
+ pthread_mutex_init(&ssl_lock_cs[i], NULL);
+
+ CRYPTO_set_id_callback(ssl_thread_id);
+ CRYPTO_set_locking_callback(ssl_lock);
+}
+#endif
+
static void change_limits(void)
{
FILE *f;
@@ -274,6 +313,10 @@ int main(int argc, char **argv)
change_limits();
+#ifdef CRYPTO_OPENSSL
+ openssl_init();
+#endif
+
if (triton_load_modules("modules"))
return EXIT_FAILURE;