aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Gouault <christophe.gouault@6wind.com>2014-04-08 17:11:13 +0200
committerTobias Brunner <tobias@strongswan.org>2014-04-24 17:54:15 +0200
commit2cbaa632951dd662e26e63299d8049c0d2bed8b1 (patch)
tree30b874666081322b7efe8f737f80eae875b078b9
parenta68454bd68221490e5504969b5378a1e86f204de (diff)
downloadstrongswan-2cbaa632951dd662e26e63299d8049c0d2bed8b1.tar.bz2
strongswan-2cbaa632951dd662e26e63299d8049c0d2bed8b1.tar.xz
load-tester: Fix race condition issuing same identity
Due to an unprotected incrementation, two load-tester initiators occasionally use the same identifier under high load. The responder typically drops one of the connections. Use an atomic incrementation to avoid this race condition. Signed-off-by: Christophe Gouault <christophe.gouault@6wind.com>
-rw-r--r--src/libcharon/plugins/load_tester/load_tester_config.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/libcharon/plugins/load_tester/load_tester_config.c b/src/libcharon/plugins/load_tester/load_tester_config.c
index e133190b4..bc7c0ffbc 100644
--- a/src/libcharon/plugins/load_tester/load_tester_config.c
+++ b/src/libcharon/plugins/load_tester/load_tester_config.c
@@ -150,7 +150,7 @@ struct private_load_tester_config_t {
/**
* incremental numbering of generated configs
*/
- u_int num;
+ refcount_t num;
/**
* Dynamic source port, if used
@@ -802,7 +802,7 @@ METHOD(backend_t, get_peer_cfg_by_name, peer_cfg_t*,
{
if (streq(name, "load-test"))
{
- return generate_config(this, this->num++);
+ return generate_config(this, (u_int)ref_get(&this->num));
}
return NULL;
}