Let's stop manually destroying the timers when we fail to spawn a child.
We don't do this in any of the similar codepaths in any of the unit
types, only in two specific ones in socket/swap. Destroying the timer is
unnecessary, since this is done anyway in the _set_state() call of each
unit type if not appropriate, and every failure path here runs through
that anyway.
This brings all these similar codepaths into sync.
r = socket_arm_timer(s, usec_add(now(CLOCK_MONOTONIC), s->timeout_usec));
if (r < 0)
- goto fail;
+ return r;
/* We have to resolve the user names out-of-process, hence
* let's fork here. It's messy, but well, what can we do? */
r = pidref_set_pid(&pidref, pid);
if (r < 0)
- goto fail;
+ return r;
r = unit_watch_pid(UNIT(s), pidref.pid, /* exclusive= */ true);
if (r < 0)
- goto fail;
+ return r;
*ret_pid = TAKE_PIDREF(pidref);
return 0;
-
-fail:
- s->timer_event_source = sd_event_source_disable_unref(s->timer_event_source);
- return r;
}
static void socket_enter_dead(Socket *s, SocketResult f) {
r = swap_arm_timer(s, usec_add(now(CLOCK_MONOTONIC), s->timeout_usec));
if (r < 0)
- goto fail;
+ return r;
r = unit_set_exec_params(UNIT(s), &exec_params);
if (r < 0)
- goto fail;
+ return r;
r = exec_spawn(UNIT(s),
c,
&s->cgroup_context,
&pid);
if (r < 0)
- goto fail;
+ return r;
r = pidref_set_pid(&pidref, pid);
if (r < 0)
- goto fail;
+ return r;
r = unit_watch_pid(UNIT(s), pidref.pid, /* exclusive= */ true);
if (r < 0)
- goto fail;
+ return r;
*ret_pid = TAKE_PIDREF(pidref);
return 0;
-
-fail:
- s->timer_event_source = sd_event_source_disable_unref(s->timer_event_source);
- return r;
}
static void swap_enter_dead(Swap *s, SwapResult f) {