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 <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2017-11-14 12:17:41 +01:00
parent 6cbeb057b8
commit 9df7cbfc52
+4
View File
@@ -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);