machined,portabled: remove unneeded NOTIFY_STOPPING

This is done internally by bus_event_loop_with_idle().
This commit is contained in:
Mike Yuan
2024-01-09 21:57:45 +08:00
parent b4a85f75b0
commit f359b3073f
3 changed files with 21 additions and 34 deletions
+9 -16
View File
@@ -320,17 +320,6 @@ static bool check_idle(void *userdata) {
return hashmap_isempty(m->machines);
}
static int manager_run(Manager *m) {
assert(m);
return bus_event_loop_with_idle(
m->event,
m->bus,
"org.freedesktop.machine1",
DEFAULT_EXIT_USEC,
check_idle, m);
}
static int run(int argc, char *argv[]) {
_cleanup_(manager_unrefp) Manager *m = NULL;
int r;
@@ -363,16 +352,20 @@ static int run(int argc, char *argv[]) {
if (r < 0)
return log_error_errno(r, "Failed to fully start up daemon: %m");
log_debug("systemd-machined running as pid "PID_FMT, getpid_cached());
r = sd_notify(false, NOTIFY_READY);
if (r < 0)
log_warning_errno(r, "Failed to send readiness notification, ignoring: %m");
r = manager_run(m);
r = bus_event_loop_with_idle(
m->event,
m->bus,
"org.freedesktop.machine1",
DEFAULT_EXIT_USEC,
check_idle, m);
if (r < 0)
return log_error_errno(r, "Failed to run main loop: %m");
(void) sd_notify(false, NOTIFY_STOPPING);
log_debug("systemd-machined stopped as pid "PID_FMT, getpid_cached());
return r;
return 0;
}
DEFINE_MAIN_FUNCTION(run);
+9 -16
View File
@@ -122,17 +122,6 @@ static bool check_idle(void *userdata) {
return !m->operations;
}
static int manager_run(Manager *m) {
assert(m);
return bus_event_loop_with_idle(
m->event,
m->bus,
"org.freedesktop.portable1",
DEFAULT_EXIT_USEC,
check_idle, m);
}
static int run(int argc, char *argv[]) {
_cleanup_(manager_unrefp) Manager *m = NULL;
int r;
@@ -162,16 +151,20 @@ static int run(int argc, char *argv[]) {
if (r < 0)
return log_error_errno(r, "Failed to fully start up daemon: %m");
log_debug("systemd-portabled running as pid " PID_FMT, getpid_cached());
r = sd_notify(false, NOTIFY_READY);
if (r < 0)
log_warning_errno(r, "Failed to send readiness notification, ignoring: %m");
r = manager_run(m);
r = bus_event_loop_with_idle(
m->event,
m->bus,
"org.freedesktop.portable1",
DEFAULT_EXIT_USEC,
check_idle, m);
if (r < 0)
return log_error_errno(r, "Failed to run main loop: %m");
(void) sd_notify(false, NOTIFY_STOPPING);
log_debug("systemd-portabled stopped as pid " PID_FMT, getpid_cached());
return r;
return 0;
}
DEFINE_MAIN_FUNCTION(run);
+3 -2
View File
@@ -18,6 +18,7 @@
#include "bus-internal.h"
#include "bus-label.h"
#include "bus-util.h"
#include "daemon-util.h"
#include "data-fd-util.h"
#include "fd-util.h"
#include "memstream-util.h"
@@ -128,8 +129,8 @@ int bus_event_loop_with_idle(
if (r == 0 && !exiting && idle) {
/* Inform the service manager that we are going down, so that it will queue all
* further start requests, instead of assuming we are already running. */
sd_notify(false, "STOPPING=1");
* further start requests, instead of assuming we are still running. */
(void) sd_notify(false, NOTIFY_STOPPING);
r = bus_async_unregister_and_exit(e, bus, name);
if (r < 0)