diff options
author | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2016-09-13 10:49:53 +0000 |
---|---|---|
committer | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2016-09-13 10:49:53 +0000 |
commit | 019b1cc4c3a3a670fef4e88633e5fb0d4aabfb43 (patch) | |
tree | 03c11e2f3148623c1a61f4132ecc574af4112125 /sbin/iked/timer.c | |
parent | 4b5e5d1986407e599871877c096a226b6f31c634 (diff) |
Disable the timer event before attempting to change it
Report and fix by Nikolay Edigaryev <edigaryev at gmail ! com>,
thanks! OK reyk@
Diffstat (limited to 'sbin/iked/timer.c')
-rw-r--r-- | sbin/iked/timer.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sbin/iked/timer.c b/sbin/iked/timer.c index 01341cbb6e0..ee28f217e28 100644 --- a/sbin/iked/timer.c +++ b/sbin/iked/timer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: timer.c,v 1.12 2015/01/16 06:39:58 deraadt Exp $ */ +/* $OpenBSD: timer.c,v 1.13 2016/09/13 10:49:52 mikeb Exp $ */ /* * Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org> @@ -37,6 +37,10 @@ void timer_set(struct iked *env, struct iked_timer *tmr, void (*cb)(struct iked *, void *), void *arg) { + 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,10 +52,6 @@ timer_add(struct iked *env, struct iked_timer *tmr, int timeout) { struct timeval tv = { timeout }; - if (evtimer_initialized(&tmr->tmr_ev) && - evtimer_pending(&tmr->tmr_ev, NULL)) - evtimer_del(&tmr->tmr_ev); - evtimer_add(&tmr->tmr_ev, &tv); } |