aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcharon/plugins/tnc_pdp/tnc_pdp_connections.c
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2012-12-19 17:55:47 +0100
committerMartin Willi <martin@revosec.ch>2013-02-14 17:19:56 +0100
commitdadd9744b60ce6a0dee2d23d7b981b28af6d5d7e (patch)
tree8a8c588e51c6679768826b4f1faa6929c372ba0f /src/libcharon/plugins/tnc_pdp/tnc_pdp_connections.c
parent37884ab10f0f40a619ba519042be94b4b473aaae (diff)
downloadstrongswan-dadd9744b60ce6a0dee2d23d7b981b28af6d5d7e.tar.bz2
strongswan-dadd9744b60ce6a0dee2d23d7b981b28af6d5d7e.tar.xz
Keep the PDP connections lock while accessing its objects
When we introduce connection timeouts, the state may disappear at any time. This change prevents that, but is not very clear. We probably have to refactor connection handling.
Diffstat (limited to 'src/libcharon/plugins/tnc_pdp/tnc_pdp_connections.c')
-rw-r--r--src/libcharon/plugins/tnc_pdp/tnc_pdp_connections.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/libcharon/plugins/tnc_pdp/tnc_pdp_connections.c b/src/libcharon/plugins/tnc_pdp/tnc_pdp_connections.c
index 7948ad2f8..3682f8f0d 100644
--- a/src/libcharon/plugins/tnc_pdp/tnc_pdp_connections.c
+++ b/src/libcharon/plugins/tnc_pdp/tnc_pdp_connections.c
@@ -67,6 +67,11 @@ struct entry_t {
* IKE SA used for bus communication
*/
ike_sa_t *ike_sa;
+
+ /**
+ * Timestamp this entry has been created
+ */
+ time_t created;
};
/**
@@ -138,6 +143,7 @@ METHOD(tnc_pdp_connections_t, add, void,
DBG1(DBG_CFG, "removed stale RADIUS connection");
entry->method = method;
entry->ike_sa = ike_sa;
+ entry->created = time_monotonic(NULL);
break;
}
}
@@ -151,6 +157,7 @@ METHOD(tnc_pdp_connections_t, add, void,
.user_name = chunk_clone(user_name),
.method = method,
.ike_sa = ike_sa,
+ .created = time_monotonic(NULL),
);
this->lock->write_lock(this->lock);
this->list->insert_last(this->list, entry);
@@ -201,12 +208,21 @@ METHOD(tnc_pdp_connections_t, get_state, eap_method_t*,
}
}
enumerator->destroy(enumerator);
- this->lock->unlock(this->lock);
+ if (!found)
+ {
+ this->lock->unlock(this->lock);
+ }
dbg_nas_user(nas_id, user_name, !found, "found");
return found;
}
+METHOD(tnc_pdp_connections_t, unlock, void,
+ private_tnc_pdp_connections_t *this)
+{
+ this->lock->unlock(this->lock);
+}
+
METHOD(tnc_pdp_connections_t, destroy, void,
private_tnc_pdp_connections_t *this)
{
@@ -227,6 +243,7 @@ tnc_pdp_connections_t *tnc_pdp_connections_create(void)
.add = _add,
.remove = _remove_,
.get_state = _get_state,
+ .unlock = _unlock,
.destroy = _destroy,
},
.list = linked_list_create(),