From: Martin Mares Date: Thu, 9 Feb 2012 21:24:54 +0000 (+0100) Subject: Main: hook_add() is guaranteed to reschedule the hook X-Git-Tag: v5.0~92 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=79cc87d28d7abb92d24ae39eae1cfad2eab0a727;p=libucw.git Main: hook_add() is guaranteed to reschedule the hook --- diff --git a/ucw/mainloop.c b/ucw/mainloop.c index 52a63489..23eed5e1 100644 --- a/ucw/mainloop.c +++ b/ucw/mainloop.c @@ -379,8 +379,9 @@ hook_add(struct main_hook *ho) struct main_context *m = main_current(); DBG("MAIN: Adding hook %p", ho); - if (!hook_is_active(ho)) - clist_add_tail(&m->hook_list, &ho->n); + if (hook_is_active(ho)) + clist_unlink(&ho->n); + clist_add_tail(&m->hook_list, &ho->n); } void diff --git a/ucw/mainloop.h b/ucw/mainloop.h index 9cd97453..0a4a8bbf 100644 --- a/ucw/mainloop.h +++ b/ucw/mainloop.h @@ -247,7 +247,8 @@ enum main_hook_return { * Inserts a new hook into the loop. * The hook will be scheduled at least once before next sleep. * May be called from inside a hook handler too. - * Adding an already added hook does nothing. + * Adding an already added hook is permitted and if the hook has been run, + * it will be run again before next sleep. **/ void hook_add(struct main_hook *ho);