From 9df7cbfc524505a4a1c7b3a9a65cff653baf04ff Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Tue, 14 Nov 2017 08:28:44 +0100 Subject: [PATCH] uev_timer_stop(): Check if already stopped to prevent double close() Both cron and regular timers were closed twice on uev_exit(), first when iterating over all watchers, next after each cb() has run in uev_run(). This patch adds a check if a watcher is active before attempting to stop it (again). Signed-off-by: Joachim Nilsson --- src/timer.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/timer.c b/src/timer.c index 481a71f..dad3d99 100644 --- a/src/timer.c +++ b/src/timer.c @@ -166,6 +166,10 @@ int uev_timer_start(uev_t *w) */ int uev_timer_stop(uev_t *w) { + /* Check if already stopped in uev_run() after cb() or _init() */ + if (!_uev_watcher_active(w)) + return 0; + /* Stop kernel timer */ uev_timer_set(w, 0, 0);