mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-10-28 11:55:23 +03:00
core: rework socket/service GC logic
There's no need to set the no_gc bit for service units that socket units prepare, as we always keep a proper reference (as maintained by unit_ref_set()) on them, and such references are honoured by the GC logic anyway. Moreover, explicitly setting the no_gc bit is problematic if the socket gets GC'ed for a reason, as the service might then leak with the bit set.
This commit is contained in:
parent
bb5049ae24
commit
e4f673174e
@ -229,7 +229,6 @@ int socket_instantiate_service(Socket *s) {
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
u->no_gc = true;
|
|
||||||
unit_ref_set(&s->service, u);
|
unit_ref_set(&s->service, u);
|
||||||
|
|
||||||
return unit_add_two_dependencies(UNIT(s), UNIT_BEFORE, UNIT_TRIGGERS, u, false);
|
return unit_add_two_dependencies(UNIT(s), UNIT_BEFORE, UNIT_TRIGGERS, u, false);
|
||||||
@ -1994,10 +1993,8 @@ static void socket_enter_running(Socket *s, int cfd) {
|
|||||||
|
|
||||||
service = SERVICE(UNIT_DEREF(s->service));
|
service = SERVICE(UNIT_DEREF(s->service));
|
||||||
unit_ref_unset(&s->service);
|
unit_ref_unset(&s->service);
|
||||||
|
|
||||||
s->n_accepted++;
|
s->n_accepted++;
|
||||||
|
|
||||||
UNIT(service)->no_gc = false;
|
|
||||||
|
|
||||||
unit_choose_id(UNIT(service), name);
|
unit_choose_id(UNIT(service), name);
|
||||||
|
|
||||||
r = service_set_socket_fd(service, cfd, s, s->selinux_context_from_net);
|
r = service_set_socket_fd(service, cfd, s, s->selinux_context_from_net);
|
||||||
|
Loading…
Reference in New Issue
Block a user