X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Fmanager.c;h=1446c01ea56f8e19be33c71f651e7218e1fe7490;hp=869c99f5c5685bd719a1c4b965d20cd98c13d118;hb=b59e246565337d6c6967059dd15a52a15277433e;hpb=a41b539efce4765c3e7a81ed308610776cc73173 diff --git a/src/core/manager.c b/src/core/manager.c index 869c99f5c..1446c01ea 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -63,6 +63,7 @@ #include "exit-status.h" #include "virt.h" #include "watchdog.h" +#include "cgroup-util.h" /* As soon as 16 units are in our GC queue, make sure to run a gc sweep */ #define GC_QUEUE_ENTRIES_MAX 16 @@ -2457,7 +2458,6 @@ static int process_event(Manager *m, struct epoll_event *ev) { int manager_loop(Manager *m) { int r; - int wait_msec = -1; RATELIMIT_DEFINE(rl, 1*USEC_PER_SEC, 50000); @@ -2476,18 +2476,12 @@ int manager_loop(Manager *m) { if (r < 0) return r; - /* Sleep for half the watchdog time */ - if (m->runtime_watchdog > 0 && m->running_as == MANAGER_SYSTEM) { - wait_msec = (int) (m->runtime_watchdog / 2 / USEC_PER_MSEC); - if (wait_msec <= 0) - wait_msec = 1; - } - while (m->exit_code == MANAGER_RUNNING) { struct epoll_event event; int n; + int wait_msec = -1; - if (wait_msec >= 0) + if (m->runtime_watchdog > 0 && m->running_as == MANAGER_SYSTEM) watchdog_ping(); if (!ratelimit_test(&rl)) { @@ -2518,6 +2512,14 @@ int manager_loop(Manager *m) { if (swap_dispatch_reload(m) > 0) continue; + /* Sleep for half the watchdog time */ + if (m->runtime_watchdog > 0 && m->running_as == MANAGER_SYSTEM) { + wait_msec = (int) (m->runtime_watchdog / 2 / USEC_PER_MSEC); + if (wait_msec <= 0) + wait_msec = 1; + } else + wait_msec = -1; + n = epoll_wait(m->epoll_fd, &event, 1, wait_msec); if (n < 0) { @@ -2611,17 +2613,13 @@ void manager_send_unit_audit(Manager *m, Unit *u, int type, bool success) { } if (audit_log_user_comm_message(m->audit_fd, type, "", p, NULL, NULL, NULL, success) < 0) { - log_warning("Failed to send audit message: %m"); - if (errno == EPERM) { /* We aren't allowed to send audit messages? - * Then let's not retry again, to avoid - * spamming the user with the same and same - * messages over and over. */ - + * Then let's not retry again. */ audit_close(m->audit_fd); m->audit_fd = -1; - } + } else + log_warning("Failed to send audit message: %m"); } free(p); @@ -3168,12 +3166,15 @@ int manager_set_default_controllers(Manager *m, char **controllers) { assert(m); - if (!(l = strv_copy(controllers))) + l = strv_copy(controllers); + if (!l) return -ENOMEM; strv_free(m->default_controllers); m->default_controllers = l; + cg_shorten_controllers(m->default_controllers); + return 0; }