From b777d2a46bd96e0a4e4b582f1cb2891ce568bb81 Mon Sep 17 00:00:00 2001 From: Andreas Steffen Date: Wed, 10 Nov 2010 21:53:17 +0100 Subject: [PATCH] implemented mutex locking the recommendations list --- src/libcharon/plugins/tnccs_20/tnccs_20.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libcharon/plugins/tnccs_20/tnccs_20.c b/src/libcharon/plugins/tnccs_20/tnccs_20.c index 075e08c..72a5288 100644 --- a/src/libcharon/plugins/tnccs_20/tnccs_20.c +++ b/src/libcharon/plugins/tnccs_20/tnccs_20.c @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -74,6 +75,11 @@ struct private_tnccs_20_t { * Action Recommendations and Evaluations Results provided by IMVs */ linked_list_t *recommendations; + + /** + * Mutex locking the recommendations list + */ + mutex_t *recommendation_mutex; }; METHOD(tnccs_t, send_message, void, @@ -100,6 +106,7 @@ METHOD(tnccs_t, provide_recommendation, void, DBG2(DBG_TNC, "IMV %u provides recommendation '%N' and evaluation '%N'", id, action_recommendation_names, rec, evaluation_result_names, eval); + this->recommendation_mutex->lock(this->recommendation_mutex); enumerator = this->recommendations->create_enumerator(this->recommendations); while (enumerator->enumerate(enumerator, &entry)) { @@ -121,6 +128,7 @@ METHOD(tnccs_t, provide_recommendation, void, /* Assign provided action recommendation and evaluation result */ entry->rec = rec; entry->eval = eval; + this->recommendation_mutex->unlock(this->recommendation_mutex); } METHOD(tls_t, process, status_t, @@ -227,6 +235,7 @@ METHOD(tls_t, destroy, void, { charon->tnccs->remove_connection(charon->tnccs, this->connection_id); this->recommendations->destroy_function(this->recommendations, free); + this->recommendation_mutex->destroy(this->recommendation_mutex); free(this->batch.ptr); free(this); } @@ -250,6 +259,7 @@ tls_t *tnccs_20_create(bool is_server) }, .is_server = is_server, .recommendations = linked_list_create(), + .recommendation_mutex = mutex_create(MUTEX_TYPE_DEFAULT), ); return &this->public; -- 2.7.4