[systemd-devel] [PATCH] timer: reenable TIMER_ACTIVE timers when restarted

Lennart Poettering lennart at poettering.net
Thu Nov 6 16:21:35 PST 2014


On Thu, 06.11.14 19:47, Michael Chapman (mike at very.puzzling.org) wrote:

Makes sense! Applied!

> A timer configured with OnActiveSec will start its associated unit again
> if the timer is stopped, then started. However, if the timer unit is
> restarted -- with "systemctl restart", say -- this does not occur.
> 
> This commit ensures that TIMER_ACTIVE timers are re-enabled whenever the
> timer is started, even if that's within a restart job.
> ---
>  src/core/timer.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/core/timer.c b/src/core/timer.c
> index a3713e2..5c4e9f9 100644
> --- a/src/core/timer.c
> +++ b/src/core/timer.c
> @@ -521,6 +521,7 @@ fail:
>  
>  static int timer_start(Unit *u) {
>          Timer *t = TIMER(u);
> +        TimerValue *v;
>  
>          assert(t);
>          assert(t->state == TIMER_DEAD || t->state == TIMER_FAILED);
> @@ -530,6 +531,11 @@ static int timer_start(Unit *u) {
>  
>          t->last_trigger = DUAL_TIMESTAMP_NULL;
>  
> +        /* Reenable all timers that depend on unit activation time */
> +        LIST_FOREACH(value, v, t->values)
> +                if (v->base == TIMER_ACTIVE)
> +                        v->disabled = false;
> +
>          if (t->stamp_path) {
>                  struct stat st;
>  
> -- 
> 2.1.0
> 
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list