core: rename and add comment to ExecParameters cleanup functions

This commit is contained in:
Luca Boccassi
2023-11-01 12:43:22 +09:00
committed by Yu Watanabe
parent f70a264cf3
commit fba173ff6a
8 changed files with 18 additions and 18 deletions
+10 -3
View File
@@ -2464,10 +2464,13 @@ void exec_runtime_clear(ExecRuntime *rt) {
rt->ephemeral_copy = mfree(rt->ephemeral_copy);
}
void exec_params_clear(ExecParameters *p) {
void exec_params_shallow_clear(ExecParameters *p) {
if (!p)
return;
/* This is called on the PID1 side, as many of the struct's FDs are only borrowed, and actually
* owned by the manager or other objects, and reused across multiple units. */
p->environment = strv_free(p->environment);
p->fd_names = strv_free(p->fd_names);
p->files_env = strv_free(p->files_env);
@@ -2481,10 +2484,14 @@ void exec_params_clear(ExecParameters *p) {
p->confirm_spawn = mfree(p->confirm_spawn);
}
void exec_params_serialized_done(ExecParameters *p) {
void exec_params_deep_clear(ExecParameters *p) {
if (!p)
return;
/* This is called on the sd-executor side, where everything received is owned by the process and has
* to be fully cleaned up to make sanitizers and analyzers happy, as opposed as the shallow clean
* function above. */
close_many_unset(p->fds, p->n_socket_fds + p->n_storage_fds);
p->cgroup_path = mfree(p->cgroup_path);
@@ -2512,7 +2519,7 @@ void exec_params_serialized_done(ExecParameters *p) {
p->fallback_smack_process_label = mfree(p->fallback_smack_process_label);
exec_params_clear(p);
exec_params_shallow_clear(p);
}
void exec_directory_done(ExecDirectory *d) {