summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorMike Belopuhov <mikeb@cvs.openbsd.org>2012-05-30 16:17:21 +0000
committerMike Belopuhov <mikeb@cvs.openbsd.org>2012-05-30 16:17:21 +0000
commit21d8e02a6b3aac1c287c211c4715b5cd90091eb0 (patch)
tree50274fde8660b4305ff6d2c6ee02307ab4028c38 /sbin
parent7a340789a731b7d3b07a2cb9c9636ac89389903d (diff)
more timer changes
Diffstat (limited to 'sbin')
-rw-r--r--sbin/iked/iked.h5
-rw-r--r--sbin/iked/ikev2.c6
-rw-r--r--sbin/iked/ikev2_pld.c4
-rw-r--r--sbin/iked/timer.c14
4 files changed, 20 insertions, 9 deletions
diff --git a/sbin/iked/iked.h b/sbin/iked/iked.h
index fe29a7510bc..38be07aa5d0 100644
--- a/sbin/iked/iked.h
+++ b/sbin/iked/iked.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: iked.h,v 1.46 2012/05/30 09:18:13 mikeb Exp $ */
+/* $OpenBSD: iked.h,v 1.47 2012/05/30 16:17:20 mikeb Exp $ */
/* $vantronix: iked.h,v 1.61 2010/06/03 07:57:33 reyk Exp $ */
/*
@@ -748,8 +748,9 @@ char *ca_asn1_name(u_int8_t *, size_t);
char *ca_x509_name(void *);
/* timer.c */
-void timer_register(struct iked_timer *, struct iked *,
+void timer_register(struct iked *, struct iked_timer *,
void (*)(struct iked *, void *), void *, int);
+void timer_deregister(struct iked *, struct iked_timer *);
/* proc.c */
void proc_init(struct privsep *, struct privsep_proc *, u_int);
diff --git a/sbin/iked/ikev2.c b/sbin/iked/ikev2.c
index a478758bfc1..9b7c2517246 100644
--- a/sbin/iked/ikev2.c
+++ b/sbin/iked/ikev2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ikev2.c,v 1.64 2012/05/30 09:39:35 mikeb Exp $ */
+/* $OpenBSD: ikev2.c,v 1.65 2012/05/30 16:17:20 mikeb Exp $ */
/* $vantronix: ikev2.c,v 1.101 2010/06/03 07:57:33 reyk Exp $ */
/*
@@ -129,7 +129,7 @@ ikev2_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg)
case IMSG_CTL_PASSIVE:
if (config_getmode(env, imsg->hdr.type) == -1)
return (0); /* ignore error */
- timer_register(&env->sc_inittmr, env, ikev2_init_ike_sa, NULL,
+ timer_register(env, &env->sc_inittmr, ikev2_init_ike_sa, NULL,
IKED_INITIATOR_INITIAL);
return (0);
case IMSG_UDP_SOCKET:
@@ -645,7 +645,7 @@ ikev2_init_ike_sa(struct iked *env, void *arg)
__func__, print_host(&pol->pol_peer.addr, NULL, 0));
}
- timer_register(&env->sc_inittmr, env, ikev2_init_ike_sa, NULL,
+ timer_register(env, &env->sc_inittmr, ikev2_init_ike_sa, NULL,
IKED_INITIATOR_INTERVAL);
}
diff --git a/sbin/iked/ikev2_pld.c b/sbin/iked/ikev2_pld.c
index 4943ea4292d..d21a3edde56 100644
--- a/sbin/iked/ikev2_pld.c
+++ b/sbin/iked/ikev2_pld.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ikev2_pld.c,v 1.24 2012/05/29 15:09:12 mikeb Exp $ */
+/* $OpenBSD: ikev2_pld.c,v 1.25 2012/05/30 16:17:20 mikeb Exp $ */
/* $vantronix: ikev2.c,v 1.101 2010/06/03 07:57:33 reyk Exp $ */
/*
@@ -705,7 +705,7 @@ ikev2_pld_notify(struct iked *env, struct ikev2_payload *pld,
group);
sa_free(env, msg->msg_sa);
msg->msg_sa = NULL;
- timer_register(&env->sc_inittmr, env, ikev2_init_ike_sa, NULL,
+ timer_register(env, &env->sc_inittmr, ikev2_init_ike_sa, NULL,
IKED_INITIATOR_INITIAL);
break;
case IKEV2_N_NO_ADDITIONAL_SAS:
diff --git a/sbin/iked/timer.c b/sbin/iked/timer.c
index 916b79d1fe8..27a09ec85c4 100644
--- a/sbin/iked/timer.c
+++ b/sbin/iked/timer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: timer.c,v 1.6 2012/05/29 15:09:12 mikeb Exp $ */
+/* $OpenBSD: timer.c,v 1.7 2012/05/30 16:17:20 mikeb Exp $ */
/*
* Copyright (c) 2010 Reyk Floeter <reyk@vantronix.net>
@@ -35,11 +35,15 @@
void timer_callback(int, short, void *);
void
-timer_register(struct iked_timer *tmr, struct iked *env,
+timer_register(struct iked *env, struct iked_timer *tmr,
void (*cb)(struct iked *, void *), void *arg, int timeout)
{
struct timeval tv = { timeout };
+ if (evtimer_initialized(&tmr->tmr_ev) &&
+ evtimer_pending(&tmr->tmr_ev, NULL))
+ evtimer_del(&tmr->tmr_ev);
+
tmr->tmr_env = env;
tmr->tmr_cb = cb;
tmr->tmr_cbarg = arg;
@@ -48,6 +52,12 @@ timer_register(struct iked_timer *tmr, struct iked *env,
}
void
+timer_deregister(struct iked *env, struct iked_timer *tmr)
+{
+ evtimer_del(&tmr->tmr_ev);
+}
+
+void
timer_callback(int fd, short event, void *arg)
{
struct iked_timer *tmr = arg;