|
|
eb8b6e |
From 567c8855016ee5e7641d6c5f1ed84badd9fae10d Mon Sep 17 00:00:00 2001
|
|
|
eb8b6e |
From: Lennart Poettering <lennart@poettering.net>
|
|
|
eb8b6e |
Date: Fri, 12 Nov 2021 09:43:07 +0100
|
|
|
eb8b6e |
Subject: [PATCH] pid1: add a manager_trigger_run_queue() helper
|
|
|
eb8b6e |
|
|
|
eb8b6e |
We have two different places where we re-trigger the run queue now.
|
|
|
eb8b6e |
let's unify it under a common function, that is part of the Manager
|
|
|
eb8b6e |
code.
|
|
|
eb8b6e |
|
|
|
eb8b6e |
Follow-up for #20953
|
|
|
eb8b6e |
|
|
|
eb8b6e |
(cherry picked from commit b0c4b2824693fe6a27ea9439ec7a6328a0e23704)
|
|
|
eb8b6e |
|
|
|
eb8b6e |
Related: #2037395
|
|
|
eb8b6e |
---
|
|
|
eb8b6e |
src/core/job.c | 5 ++---
|
|
|
eb8b6e |
src/core/manager.c | 12 ++++++++++++
|
|
|
eb8b6e |
src/core/manager.h | 2 ++
|
|
|
eb8b6e |
src/core/mount.c | 9 +++------
|
|
|
eb8b6e |
4 files changed, 19 insertions(+), 9 deletions(-)
|
|
|
eb8b6e |
|
|
|
eb8b6e |
diff --git a/src/core/job.c b/src/core/job.c
|
|
|
eb8b6e |
index 870ec0a387..cc6e1ee65a 100644
|
|
|
eb8b6e |
--- a/src/core/job.c
|
|
|
eb8b6e |
+++ b/src/core/job.c
|
|
|
eb8b6e |
@@ -1137,11 +1137,10 @@ void job_add_to_run_queue(Job *j) {
|
|
|
eb8b6e |
if (j->in_run_queue)
|
|
|
eb8b6e |
return;
|
|
|
eb8b6e |
|
|
|
eb8b6e |
- if (!j->manager->run_queue)
|
|
|
eb8b6e |
- sd_event_source_set_enabled(j->manager->run_queue_event_source, SD_EVENT_ONESHOT);
|
|
|
eb8b6e |
-
|
|
|
eb8b6e |
LIST_PREPEND(run_queue, j->manager->run_queue, j);
|
|
|
eb8b6e |
j->in_run_queue = true;
|
|
|
eb8b6e |
+
|
|
|
eb8b6e |
+ manager_trigger_run_queue(j->manager);
|
|
|
eb8b6e |
}
|
|
|
eb8b6e |
|
|
|
eb8b6e |
void job_add_to_dbus_queue(Job *j) {
|
|
|
eb8b6e |
diff --git a/src/core/manager.c b/src/core/manager.c
|
|
|
eb8b6e |
index 3c44ad3dbc..ae6ce35d99 100644
|
|
|
eb8b6e |
--- a/src/core/manager.c
|
|
|
eb8b6e |
+++ b/src/core/manager.c
|
|
|
eb8b6e |
@@ -2120,6 +2120,18 @@ static int manager_dispatch_run_queue(sd_event_source *source, void *userdata) {
|
|
|
eb8b6e |
return 1;
|
|
|
eb8b6e |
}
|
|
|
eb8b6e |
|
|
|
eb8b6e |
+void manager_trigger_run_queue(Manager *m) {
|
|
|
eb8b6e |
+ int r;
|
|
|
eb8b6e |
+
|
|
|
eb8b6e |
+ assert(m);
|
|
|
eb8b6e |
+
|
|
|
eb8b6e |
+ r = sd_event_source_set_enabled(
|
|
|
eb8b6e |
+ m->run_queue_event_source,
|
|
|
eb8b6e |
+ m->run_queue ? SD_EVENT_ONESHOT: SD_EVENT_OFF);
|
|
|
eb8b6e |
+ if (r < 0)
|
|
|
eb8b6e |
+ log_warning_errno(r, "Failed to enable job run queue event source, ignoring: %m");
|
|
|
eb8b6e |
+}
|
|
|
eb8b6e |
+
|
|
|
eb8b6e |
static unsigned manager_dispatch_dbus_queue(Manager *m) {
|
|
|
eb8b6e |
unsigned n = 0, budget;
|
|
|
eb8b6e |
Unit *u;
|
|
|
eb8b6e |
diff --git a/src/core/manager.h b/src/core/manager.h
|
|
|
eb8b6e |
index c4b8e80093..7b572c8dfd 100644
|
|
|
eb8b6e |
--- a/src/core/manager.h
|
|
|
eb8b6e |
+++ b/src/core/manager.h
|
|
|
eb8b6e |
@@ -416,6 +416,8 @@ unsigned manager_dispatch_load_queue(Manager *m);
|
|
|
eb8b6e |
int manager_environment_add(Manager *m, char **minus, char **plus);
|
|
|
eb8b6e |
int manager_set_default_rlimits(Manager *m, struct rlimit **default_rlimit);
|
|
|
eb8b6e |
|
|
|
eb8b6e |
+void manager_trigger_run_queue(Manager *m);
|
|
|
eb8b6e |
+
|
|
|
eb8b6e |
int manager_loop(Manager *m);
|
|
|
eb8b6e |
|
|
|
eb8b6e |
int manager_open_serialization(Manager *m, FILE **_f);
|
|
|
eb8b6e |
diff --git a/src/core/mount.c b/src/core/mount.c
|
|
|
eb8b6e |
index c05779343c..9ff7c71edd 100644
|
|
|
eb8b6e |
--- a/src/core/mount.c
|
|
|
eb8b6e |
+++ b/src/core/mount.c
|
|
|
eb8b6e |
@@ -1708,15 +1708,12 @@ static bool mount_is_mounted(Mount *m) {
|
|
|
eb8b6e |
|
|
|
eb8b6e |
static int mount_on_ratelimit_expire(sd_event_source *s, void *userdata) {
|
|
|
eb8b6e |
Manager *m = userdata;
|
|
|
eb8b6e |
- int r;
|
|
|
eb8b6e |
|
|
|
eb8b6e |
assert(m);
|
|
|
eb8b6e |
|
|
|
eb8b6e |
- /* By entering ratelimited state we made all mount start jobs not runnable, now rate limit is over so let's
|
|
|
eb8b6e |
- * make sure we dispatch them in the next iteration. */
|
|
|
eb8b6e |
- r = sd_event_source_set_enabled(m->run_queue_event_source, SD_EVENT_ONESHOT);
|
|
|
eb8b6e |
- if (r < 0)
|
|
|
eb8b6e |
- log_debug_errno(r, "Failed to enable run queue event source, ignoring: %m");
|
|
|
eb8b6e |
+ /* By entering ratelimited state we made all mount start jobs not runnable, now rate limit is over so
|
|
|
eb8b6e |
+ * let's make sure we dispatch them in the next iteration. */
|
|
|
eb8b6e |
+ manager_trigger_run_queue(m);
|
|
|
eb8b6e |
|
|
|
eb8b6e |
return 0;
|
|
|
eb8b6e |
}
|