From: Yu Watanabe Date: Wed, 9 Oct 2024 16:50:29 +0000 (+0900) Subject: logind: add comment why we save action in execute_shutdown_or_sleep() X-Git-Tag: v257-rc1~269^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=0bba5435733bd5228c384d155a51dd44b9c92fb9;p=thirdparty%2Fsystemd.git logind: add comment why we save action in execute_shutdown_or_sleep() When I first read the code, I was confused about that. Hopefully, this helps maintain code a bit. --- diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index b688eab0cde..35549e663a0 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -1899,15 +1899,18 @@ static int execute_shutdown_or_sleep( if (r < 0) goto fail; + /* Save the action to prevent another request of shutdown or friends before the current action being + * finished. See method_do_shutdown_or_sleep(). This is also used in match_job_removed() to log what + * kind of action is finished. */ m->delayed_action = a; - /* Make sure the lid switch is ignored for a while */ + /* Make sure the lid switch is ignored for a while. */ manager_set_lid_switch_ignore(m, usec_add(now(CLOCK_MONOTONIC), m->holdoff_timeout_usec)); return 0; fail: - /* Tell people that they now may take a lock again */ + /* Tell people that they now may take a lock again. */ (void) send_prepare_for(m, a, false); return r;