diff options
| -rw-r--r-- | meta/recipes-core/systemd/systemd/0003-timedated-Respond-on-org.freedesktop.timedate1.SetNT.patch | 97 | ||||
| -rw-r--r-- | meta/recipes-core/systemd/systemd_255.21.bb | 1 |
2 files changed, 98 insertions, 0 deletions
diff --git a/meta/recipes-core/systemd/systemd/0003-timedated-Respond-on-org.freedesktop.timedate1.SetNT.patch b/meta/recipes-core/systemd/systemd/0003-timedated-Respond-on-org.freedesktop.timedate1.SetNT.patch new file mode 100644 index 0000000000..c1d8a94bf7 --- /dev/null +++ b/meta/recipes-core/systemd/systemd/0003-timedated-Respond-on-org.freedesktop.timedate1.SetNT.patch | |||
| @@ -0,0 +1,97 @@ | |||
| 1 | From 3a51e31be9f626cf772733cb289ed64739fab0e4 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: =?UTF-8?q?Michal=20Koutn=C3=BD?= <mkoutny@suse.com> | ||
| 3 | Date: Tue, 20 Feb 2024 19:26:16 +0100 | ||
| 4 | Subject: [PATCH] timedated: Respond on org.freedesktop.timedate1.SetNTP only | ||
| 5 | when really finished | ||
| 6 | |||
| 7 | The method returns prematurely (before jobs it triggers terminate). This | ||
| 8 | is externally visible because other methods may fail if jobs did not | ||
| 9 | finish. | ||
| 10 | Postpone the DBus method response until we collect all signals for | ||
| 11 | finished jobs. | ||
| 12 | systemd-timedated keeps track of in-flight DBus requests and answers | ||
| 13 | them all in unspecified order when jobs finish. The capacity of requests | ||
| 14 | in systemd-timedated is limited. | ||
| 15 | |||
| 16 | Fixes: #17739 | ||
| 17 | |||
| 18 | Upstream-Status: Backport [https://github.com/systemd/systemd/commit/3a51e31be9f626cf772733cb289ed64739fab0e4] | ||
| 19 | Signed-off-by: Michal Seben <michal.seben@siemens.com> | ||
| 20 | --- | ||
| 21 | src/timedate/timedated.c | 21 ++++++++++++++++++--- | ||
| 22 | 1 file changed, 18 insertions(+), 3 deletions(-) | ||
| 23 | |||
| 24 | Index: git/src/timedate/timedated.c | ||
| 25 | =================================================================== | ||
| 26 | --- git.orig/src/timedate/timedated.c | ||
| 27 | +++ git/src/timedate/timedated.c | ||
| 28 | @@ -45,6 +45,7 @@ | ||
| 29 | #define NULL_ADJTIME_LOCAL "0.0 0 0\n0\nLOCAL\n" | ||
| 30 | |||
| 31 | #define UNIT_LIST_DIRS (const char* const*) CONF_PATHS_STRV("systemd/ntp-units.d") | ||
| 32 | +#define SET_NTP_IN_FLIGHT_MAX 16 | ||
| 33 | |||
| 34 | typedef struct UnitStatusInfo { | ||
| 35 | char *name; | ||
| 36 | @@ -61,6 +62,7 @@ typedef struct Context { | ||
| 37 | bool local_rtc; | ||
| 38 | Hashmap *polkit_registry; | ||
| 39 | sd_bus_message *cache; | ||
| 40 | + Set *set_ntp_calls; | ||
| 41 | |||
| 42 | sd_bus_slot *slot_job_removed; | ||
| 43 | |||
| 44 | @@ -121,6 +123,7 @@ static void context_clear(Context *c) { | ||
| 45 | free(c->zone); | ||
| 46 | bus_verify_polkit_async_registry_free(c->polkit_registry); | ||
| 47 | sd_bus_message_unref(c->cache); | ||
| 48 | + set_free(c->set_ntp_calls); | ||
| 49 | |||
| 50 | sd_bus_slot_unref(c->slot_job_removed); | ||
| 51 | |||
| 52 | @@ -461,11 +464,19 @@ static int match_job_removed(sd_bus_mess | ||
| 53 | n += !!u->path; | ||
| 54 | |||
| 55 | if (n == 0) { | ||
| 56 | + sd_bus_message *cm; | ||
| 57 | + | ||
| 58 | c->slot_job_removed = sd_bus_slot_unref(c->slot_job_removed); | ||
| 59 | |||
| 60 | (void) sd_bus_emit_properties_changed(sd_bus_message_get_bus(m), | ||
| 61 | "/org/freedesktop/timedate1", "org.freedesktop.timedate1", "NTP", | ||
| 62 | NULL); | ||
| 63 | + while ((cm = set_steal_first(c->set_ntp_calls))) { | ||
| 64 | + r = sd_bus_reply_method_return(cm, NULL); | ||
| 65 | + if (r < 0) | ||
| 66 | + log_debug_errno(r, "Failed to reply to SetNTP method call, ignoring: %m"); | ||
| 67 | + sd_bus_message_unref(cm); | ||
| 68 | + } | ||
| 69 | } | ||
| 70 | |||
| 71 | return 0; | ||
| 72 | @@ -944,6 +955,9 @@ static int method_set_ntp(sd_bus_message | ||
| 73 | LIST_FOREACH(units, u, c->units) | ||
| 74 | u->path = mfree(u->path); | ||
| 75 | |||
| 76 | + if (set_size(c->set_ntp_calls) >= SET_NTP_IN_FLIGHT_MAX) | ||
| 77 | + return sd_bus_error_set_errnof(error, EAGAIN, "Too many calls in flight."); | ||
| 78 | + | ||
| 79 | if (!c->slot_job_removed) { | ||
| 80 | r = bus_match_signal_async( | ||
| 81 | bus, | ||
| 82 | @@ -998,11 +1012,12 @@ static int method_set_ntp(sd_bus_message | ||
| 83 | c->slot_job_removed = TAKE_PTR(slot); | ||
| 84 | |||
| 85 | if (selected) | ||
| 86 | - log_info("Set NTP to enabled (%s).", selected->name); | ||
| 87 | + log_info("Set NTP to be enabled (%s).", selected->name); | ||
| 88 | else | ||
| 89 | - log_info("Set NTP to disabled."); | ||
| 90 | + log_info("Set NTP to be disabled."); | ||
| 91 | |||
| 92 | - return sd_bus_reply_method_return(m, NULL); | ||
| 93 | + /* Asynchrounous reply to m in match_job_removed() */ | ||
| 94 | + return set_ensure_consume(&c->set_ntp_calls, &bus_message_hash_ops, sd_bus_message_ref(m)); | ||
| 95 | } | ||
| 96 | |||
| 97 | static int method_list_timezones(sd_bus_message *m, void *userdata, sd_bus_error *error) { | ||
diff --git a/meta/recipes-core/systemd/systemd_255.21.bb b/meta/recipes-core/systemd/systemd_255.21.bb index bb9dc3da33..e866f9921b 100644 --- a/meta/recipes-core/systemd/systemd_255.21.bb +++ b/meta/recipes-core/systemd/systemd_255.21.bb | |||
| @@ -27,6 +27,7 @@ SRC_URI += " \ | |||
| 27 | file://99-default.preset \ | 27 | file://99-default.preset \ |
| 28 | file://systemd-pager.sh \ | 28 | file://systemd-pager.sh \ |
| 29 | file://0002-binfmt-Don-t-install-dependency-links-at-install-tim.patch \ | 29 | file://0002-binfmt-Don-t-install-dependency-links-at-install-tim.patch \ |
| 30 | file://0003-timedated-Respond-on-org.freedesktop.timedate1.SetNT.patch \ | ||
| 30 | file://0008-implment-systemd-sysv-install-for-OE.patch \ | 31 | file://0008-implment-systemd-sysv-install-for-OE.patch \ |
| 31 | " | 32 | " |
| 32 | 33 | ||
