aboutsummaryrefslogtreecommitdiffstats
path: root/src/libhydra/plugins/kernel_pfroute
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2013-05-06 16:40:19 +0200
committerMartin Willi <martin@revosec.ch>2013-05-06 17:01:13 +0200
commitc9a323c1d970b4c28ae6a3c2bba1b55c539346d1 (patch)
tree1c710356ddd17e17a9598cdc640e99210d897145 /src/libhydra/plugins/kernel_pfroute
parent5c12700f9abc5efeb38d18a46edf152894476e8c (diff)
downloadstrongswan-c9a323c1d9.tar.bz2
strongswan-c9a323c1d9.tar.xz
kernel-pfroute: allow only one thread to do a route look up simultaneously
Otherwise we mess up the sequence number another thread is waiting for.
Diffstat (limited to 'src/libhydra/plugins/kernel_pfroute')
-rw-r--r--src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c b/src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c
index 8d8d0362a..6c0b457c5 100644
--- a/src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c
+++ b/src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c
@@ -668,7 +668,7 @@ static job_requeue_t receive_events(private_kernel_pfroute_net_t *this)
memcpy(this->reply, &msg, msg.rtm.rtm_msglen);
}
/* signal on any event, add_ip()/del_ip() might wait for it */
- this->condvar->signal(this->condvar);
+ this->condvar->broadcast(this->condvar);
this->mutex->unlock(this->mutex);
return JOB_REQUEUE_DIRECT;
@@ -1122,6 +1122,10 @@ METHOD(kernel_net_t, get_nexthop, host_t*,
}
this->mutex->lock(this->mutex);
+ while (this->waiting_seq)
+ {
+ this->condvar->wait(this->condvar, this->mutex);
+ }
this->waiting_seq = msg.hdr.rtm_seq;
if (send(this->socket, &msg, msg.hdr.rtm_msglen, 0) == msg.hdr.rtm_msglen)
{
@@ -1154,6 +1158,9 @@ METHOD(kernel_net_t, get_nexthop, host_t*,
{
DBG1(DBG_KNL, "PF_ROUTE lookup failed: %s", strerror(errno));
}
+ /* signal completion of query to a waiting thread */
+ this->waiting_seq = 0;
+ this->condvar->signal(this->condvar);
this->mutex->unlock(this->mutex);
return hop;