main: add commenting, clean up handling of saved resource limits

This doesn't really change behaviour, but adds comments and uses more
symbolic names for everything, to make this more readable.
This commit is contained in:
Lennart Poettering
2019-01-18 17:31:36 +01:00
parent c0d7695908
commit ddfa8b0b3b
+9 -6
View File
@@ -1675,12 +1675,11 @@ static void do_reexecute(
* we do that */
watchdog_close(true);
/* Reset the RLIMIT_NOFILE to the kernel default, so that the new systemd can pass the kernel default to its
* child processes */
if (saved_rlimit_nofile->rlim_cur > 0)
/* Reset RLIMIT_NOFILE + RLIMIT_MEMLOCK back to the kernel defaults, so that the new systemd can pass
* the kernel default to its child processes */
if (saved_rlimit_nofile->rlim_cur != 0)
(void) setrlimit(RLIMIT_NOFILE, saved_rlimit_nofile);
if (saved_rlimit_memlock->rlim_cur != (rlim_t) -1)
if (saved_rlimit_memlock->rlim_cur != RLIM_INFINITY)
(void) setrlimit(RLIMIT_MEMLOCK, saved_rlimit_memlock);
if (switch_root_dir) {
@@ -2313,7 +2312,11 @@ int main(int argc, char *argv[]) {
dual_timestamp initrd_timestamp = DUAL_TIMESTAMP_NULL, userspace_timestamp = DUAL_TIMESTAMP_NULL, kernel_timestamp = DUAL_TIMESTAMP_NULL,
security_start_timestamp = DUAL_TIMESTAMP_NULL, security_finish_timestamp = DUAL_TIMESTAMP_NULL;
struct rlimit saved_rlimit_nofile = RLIMIT_MAKE_CONST(0), saved_rlimit_memlock = RLIMIT_MAKE_CONST((rlim_t) -1);
struct rlimit saved_rlimit_nofile = RLIMIT_MAKE_CONST(0),
saved_rlimit_memlock = RLIMIT_MAKE_CONST(RLIM_INFINITY); /* The original rlimits we passed
* in. Note we use different values
* for the two that indicate whether
* these fields are initialized! */
bool skip_setup, loaded_policy = false, queue_default_job = false, first_boot = false, reexecute = false;
char *switch_root_dir = NULL, *switch_root_init = NULL;
usec_t before_startup, after_startup;