aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2008-12-09 15:57:51 +0000
committerMartin Willi <martin@strongswan.org>2008-12-09 15:57:51 +0000
commitd5d5bc0f16e060abdcbd3e8ecba31dbd9de6cba0 (patch)
tree2af47a909d42ea23b1ebdcbb3b8356b1aadaf714 /src
parent5e5b2dc105d1cfcc29cc6a5aaef975286b6596ae (diff)
downloadstrongswan-d5d5bc0f16e060abdcbd3e8ecba31dbd9de6cba0.tar.bz2
strongswan-d5d5bc0f16e060abdcbd3e8ecba31dbd9de6cba0.tar.xz
using rwlock to parallel build credentials
Diffstat (limited to 'src')
-rw-r--r--src/libstrongswan/credentials/credential_factory.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/libstrongswan/credentials/credential_factory.c b/src/libstrongswan/credentials/credential_factory.c
index e4e0ce8c5..201fe019d 100644
--- a/src/libstrongswan/credentials/credential_factory.c
+++ b/src/libstrongswan/credentials/credential_factory.c
@@ -46,9 +46,9 @@ struct private_credential_factory_t {
linked_list_t *constructors;
/**
- * mutex to lock access to modules
+ * lock access to builders
*/
- mutex_t *mutex;
+ rwlock_t *lock;
};
typedef struct entry_t entry_t;
@@ -86,12 +86,12 @@ static enumerator_t* create_builder_enumerator(
data->type = type;
data->subtype = subtype;
- this->mutex->lock(this->mutex);
+ this->lock->read_lock(this->lock);
return enumerator_create_cleaner(
enumerator_create_filter(
this->constructors->create_enumerator(this->constructors),
(void*)builder_filter, data, free),
- (void*)this->mutex->unlock, this->mutex);
+ (void*)this->lock->unlock, this->lock);
}
/**
@@ -106,9 +106,9 @@ static void add_builder(private_credential_factory_t *this,
entry->type = type;
entry->subtype = subtype;
entry->constructor = constructor;
- this->mutex->lock(this->mutex);
+ this->lock->write_lock(this->lock);
this->constructors->insert_last(this->constructors, entry);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
}
/**
@@ -120,7 +120,7 @@ static void remove_builder(private_credential_factory_t *this,
enumerator_t *enumerator;
entry_t *entry;
- this->mutex->lock(this->mutex);
+ this->lock->write_lock(this->lock);
enumerator = this->constructors->create_enumerator(this->constructors);
while (enumerator->enumerate(enumerator, &entry))
{
@@ -131,7 +131,7 @@ static void remove_builder(private_credential_factory_t *this,
}
}
enumerator->destroy(enumerator);
- this->mutex->unlock(this->mutex);
+ this->lock->unlock(this->lock);
}
/**
@@ -215,7 +215,7 @@ static void* create(private_credential_factory_t *this, credential_type_t type,
static void destroy(private_credential_factory_t *this)
{
this->constructors->destroy_function(this->constructors, free);
- this->mutex->destroy(this->mutex);
+ this->lock->destroy(this->lock);
free(this);
}
@@ -234,7 +234,7 @@ credential_factory_t *credential_factory_create()
this->constructors = linked_list_create();
- this->mutex = mutex_create(MUTEX_RECURSIVE);
+ this->lock = rwlock_create(RWLOCK_DEFAULT);
return &this->public;
}