aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstrongswan/plugins
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2008-11-05 11:29:56 +0000
committerMartin Willi <martin@strongswan.org>2008-11-05 11:29:56 +0000
commit3ac5a0db8ca620ab1eb536dbc742c3acf8325b98 (patch)
treee596d9640c2d39f8ff5d8be0f92fc2ce95d3b688 /src/libstrongswan/plugins
parent2662806b2c6c898717893d5e00958ae89f245c91 (diff)
downloadstrongswan-3ac5a0db8ca620ab1eb536dbc742c3acf8325b98.tar.bz2
strongswan-3ac5a0db8ca620ab1eb536dbc742c3acf8325b98.tar.xz
replaced most pthread_mutex/cond_t by wrapped mutex/condvar_t variant
Diffstat (limited to 'src/libstrongswan/plugins')
-rw-r--r--src/libstrongswan/plugins/openssl/openssl_plugin.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/libstrongswan/plugins/openssl/openssl_plugin.c b/src/libstrongswan/plugins/openssl/openssl_plugin.c
index 39c4af99a..744b6e89a 100644
--- a/src/libstrongswan/plugins/openssl/openssl_plugin.c
+++ b/src/libstrongswan/plugins/openssl/openssl_plugin.c
@@ -24,6 +24,7 @@
#include "openssl_plugin.h"
#include <library.h>
+#include <utils/mutex.h>
#include "openssl_crypter.h"
#include "openssl_hasher.h"
#include "openssl_diffie_hellman.h"
@@ -49,7 +50,7 @@ struct private_openssl_plugin_t {
/**
* Array of static mutexs, with CRYPTO_num_locks() mutex
*/
-static pthread_mutex_t *mutex;
+static mutex_t **mutex;
/**
* Locking callback for static locks
@@ -58,11 +59,11 @@ static void locking_function(int mode, int type, const char *file, int line)
{
if (mode & CRYPTO_LOCK)
{
- pthread_mutex_lock(&mutex[type]);
+ mutex[type]->lock(mutex[type]);
}
else
{
- pthread_mutex_unlock(&mutex[type]);
+ mutex[type]->unlock(mutex[type]);
}
}
@@ -70,7 +71,7 @@ static void locking_function(int mode, int type, const char *file, int line)
* Implementation of dynlock
*/
struct CRYPTO_dynlock_value {
- pthread_mutex_t mutex;
+ mutex_t *mutex;
};
/**
@@ -81,7 +82,7 @@ static struct CRYPTO_dynlock_value *create_function(const char *file, int line)
struct CRYPTO_dynlock_value *lock;
lock = malloc_thing(struct CRYPTO_dynlock_value);
- pthread_mutex_init(&lock->mutex, NULL);
+ lock->mutex = mutex_create(MUTEX_DEFAULT);
return lock;
}
@@ -93,11 +94,11 @@ static void lock_function(int mode, struct CRYPTO_dynlock_value *lock,
{
if (mode & CRYPTO_LOCK)
{
- pthread_mutex_lock(&lock->mutex);
+ lock->mutex->lock(lock->mutex);
}
else
{
- pthread_mutex_unlock(&lock->mutex);
+ lock->mutex->unlock(lock->mutex);
}
}
@@ -107,7 +108,7 @@ static void lock_function(int mode, struct CRYPTO_dynlock_value *lock,
static void destroy_function(struct CRYPTO_dynlock_value *lock,
const char *file, int line)
{
- pthread_mutex_destroy(&lock->mutex);
+ lock->mutex->destroy(lock->mutex);
free(lock);
}
@@ -134,10 +135,10 @@ static void threading_init()
CRYPTO_set_dynlock_destroy_callback(destroy_function);
num_locks = CRYPTO_num_locks();
- mutex = malloc(sizeof(pthread_mutex_t) * num_locks);
+ mutex = malloc(sizeof(mutex_t*) * num_locks);
for (i = 0; i < num_locks; i++)
{
- pthread_mutex_init(&mutex[i], NULL);
+ mutex[i] = mutex_create(MUTEX_DEFAULT);
}
}
@@ -151,7 +152,7 @@ static void threading_cleanup()
num_locks = CRYPTO_num_locks();
for (i = 0; i < num_locks; i++)
{
- pthread_mutex_destroy(&mutex[i]);
+ mutex[i]->destroy(mutex[i]);
}
free(mutex);
}
@@ -181,8 +182,6 @@ static void destroy(private_openssl_plugin_t *this)
ENGINE_cleanup();
EVP_cleanup();
- threading_cleanup();
-
free(this);
}