core: split out cgroup specific state fields from Unit → CGroupRuntime
This refactors the Unit structure a bit: all cgroup-related state fields
are moved to a new structure CGroupRuntime, which is only allocated as
we realize a cgroup.
This is both a nice cleanup and should make unit structures considerably
smaller that have no cgroup associated, because never realized or
because they belong to a unit type that doesn#t have cgroups anyway.
This makes things nicely symmetric:
ExecContext → static user configuration about execution
ExecRuntime → dynamic user state of execution
CGroupContext → static user configuration about cgroups
CGroupRuntime → dynamic user state of cgroups
And each time the XyzContext is part of the unit type structures such as
Service or Slice that need it, but the runtime object is only allocated
when a unit is started.
This commit is contained in:
+4
-1
@@ -167,6 +167,7 @@ static void socket_done(Unit *u) {
|
||||
s->peers_by_address = set_free(s->peers_by_address);
|
||||
|
||||
s->exec_runtime = exec_runtime_free(s->exec_runtime);
|
||||
|
||||
exec_command_free_array(s->exec_command, _SOCKET_EXEC_COMMAND_MAX);
|
||||
s->control_command = NULL;
|
||||
|
||||
@@ -2473,7 +2474,8 @@ static int socket_start(Unit *u) {
|
||||
s->result = SOCKET_SUCCESS;
|
||||
exec_command_reset_status_list_array(s->exec_command, _SOCKET_EXEC_COMMAND_MAX);
|
||||
|
||||
u->reset_accounting = true;
|
||||
if (s->cgroup_runtime)
|
||||
s->cgroup_runtime->reset_accounting = true;
|
||||
|
||||
socket_enter_start_pre(s);
|
||||
return 1;
|
||||
@@ -3528,6 +3530,7 @@ const UnitVTable socket_vtable = {
|
||||
.cgroup_context_offset = offsetof(Socket, cgroup_context),
|
||||
.kill_context_offset = offsetof(Socket, kill_context),
|
||||
.exec_runtime_offset = offsetof(Socket, exec_runtime),
|
||||
.cgroup_runtime_offset = offsetof(Socket, cgroup_runtime),
|
||||
|
||||
.sections =
|
||||
"Unit\0"
|
||||
|
||||
Reference in New Issue
Block a user