mirror of
https://github.com/systemd/systemd.git
synced 2025-01-31 05:47:30 +03:00
core: don't manually destroy timer when we can't spawn a child
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.
This commit is contained in:
parent
436cdf0a07
commit
894a30ef3f
@ -1976,7 +1976,7 @@ static int socket_chown(Socket *s, PidRef *ret_pid) {
|
||||
|
||||
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? */
|
||||
@ -2032,18 +2032,14 @@ static int socket_chown(Socket *s, PidRef *ret_pid) {
|
||||
|
||||
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) {
|
||||
|
@ -677,11 +677,11 @@ static int swap_spawn(Swap *s, ExecCommand *c, PidRef *ret_pid) {
|
||||
|
||||
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,
|
||||
@ -691,22 +691,18 @@ static int swap_spawn(Swap *s, ExecCommand *c, PidRef *ret_pid) {
|
||||
&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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user