aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Steffen <andreas.steffen@strongswan.org>2010-11-10 22:22:27 +0100
committerAndreas Steffen <andreas.steffen@strongswan.org>2010-11-10 22:22:27 +0100
commit3db904641ebb5dfbd72b8baa9f4df0287326ae80 (patch)
treeeb6dedf48e681c1ee13953bdc5a7d9581f087555
parentc0cb1f8a09fcc157dc2ad75775afc17340d8342d (diff)
downloadstrongswan-3db904641ebb5dfbd72b8baa9f4df0287326ae80.tar.bz2
strongswan-3db904641ebb5dfbd72b8baa9f4df0287326ae80.tar.xz
implemented mutex locking the batch in construction
-rw-r--r--src/libcharon/plugins/tnccs_20/tnccs_20.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/libcharon/plugins/tnccs_20/tnccs_20.c b/src/libcharon/plugins/tnccs_20/tnccs_20.c
index fd76680a1..10365d6b0 100644
--- a/src/libcharon/plugins/tnccs_20/tnccs_20.c
+++ b/src/libcharon/plugins/tnccs_20/tnccs_20.c
@@ -72,6 +72,11 @@ struct private_tnccs_20_t {
chunk_t batch;
/**
+ * Mutex locking the batch in construction
+ */
+ mutex_t *batch_mutex;
+
+ /**
* Action Recommendations and Evaluations Results provided by IMVs
*/
linked_list_t *recommendations;
@@ -87,11 +92,12 @@ METHOD(tnccs_t, send_message, void,
TNC_UInt32 message_len,
TNC_MessageType message_type)
{
- chunk_t msg = { message, message_len },
- batch = this->batch;
+ chunk_t msg = { message, message_len };
DBG1(DBG_TNC, "TNCCS 2.0 send message");
- this->batch = chunk_cat("mc", batch, msg);
+ this->batch_mutex->lock(this->batch_mutex);
+ this->batch = chunk_cat("mc", this->batch, msg);
+ this->batch_mutex->unlock(this->batch_mutex);
}
METHOD(tnccs_t, provide_recommendation, void,
@@ -181,7 +187,9 @@ METHOD(tls_t, build, status_t,
char *msg = this->is_server ? "tncs->tncc 2.0|" : "tncc->tncs 2.0|";
size_t len;
+ this->batch_mutex->lock(this->batch_mutex);
this->batch = chunk_cat("cm", chunk_create(msg, strlen(msg)), this->batch);
+ this->batch_mutex->unlock(this->batch_mutex);
if (!this->is_server && !this->connection_id)
{
@@ -194,15 +202,17 @@ METHOD(tls_t, build, status_t,
charon->imcs->begin_handshake(charon->imcs, this->connection_id);
}
+ this->batch_mutex->lock(this->batch_mutex);
len = this->batch.len;
*msglen = len;
*buflen = len;
memcpy(buf, this->batch.ptr, len);
+ chunk_free(&this->batch);
+ this->batch_mutex->unlock(this->batch_mutex);
DBG1(DBG_TNC, "sending TNCCS Batch (%d bytes) for Connection ID %u",
len, this->connection_id);
DBG3(DBG_TNC, "%.*s", len, buf);
- chunk_free(&this->batch);
return ALREADY_DONE;
}
@@ -237,6 +247,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);
+ this->batch_mutex->destroy(this->batch_mutex);
free(this->batch.ptr);
free(this);
}
@@ -261,6 +272,7 @@ tls_t *tnccs_20_create(bool is_server)
.is_server = is_server,
.recommendations = linked_list_create(),
.recommendation_mutex = mutex_create(MUTEX_TYPE_DEFAULT),
+ .batch_mutex = mutex_create(MUTEX_TYPE_DEFAULT),
);
return &this->public;