summaryrefslogtreecommitdiffstats
path: root/src/resolve
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-05-10 14:44:15 +0200
committerGitHub <noreply@github.com>2021-05-10 14:44:15 +0200
commit2d0b71b6f6eb3a91340eab39c222fcf6885c2005 (patch)
treec5ca922c7ac1bb2083ae834b4a4c39ef498bde29 /src/resolve
parentMerge pull request #19556 from lucasrangit/network-wifi-interface-type-typos (diff)
parentresolve: check that bus is ready before emitting signal or property change (diff)
downloadsystemd-2d0b71b6f6eb3a91340eab39c222fcf6885c2005.tar.xz
systemd-2d0b71b6f6eb3a91340eab39c222fcf6885c2005.zip
Merge pull request #19542 from yuwata/unit-after-socket
network, timesync, resolve: check bus is ready before emitting property change or signal
Diffstat (limited to 'src/resolve')
-rw-r--r--src/resolve/resolved-bus.c3
-rw-r--r--src/resolve/resolved-dns-zone.c2
-rw-r--r--src/resolve/resolved-dnssd.c19
-rw-r--r--src/resolve/resolved-dnssd.h2
4 files changed, 15 insertions, 11 deletions
diff --git a/src/resolve/resolved-bus.c b/src/resolve/resolved-bus.c
index 31c96706a2..7226200f00 100644
--- a/src/resolve/resolved-bus.c
+++ b/src/resolve/resolved-bus.c
@@ -2272,6 +2272,9 @@ int manager_connect_bus(Manager *m) {
int _manager_send_changed(Manager *manager, const char *property, ...) {
assert(manager);
+ if (sd_bus_is_ready(manager->bus) <= 0)
+ return 0;
+
char **l = strv_from_stdarg_alloca(property);
int r = sd_bus_emit_properties_changed_strv(
diff --git a/src/resolve/resolved-dns-zone.c b/src/resolve/resolved-dns-zone.c
index 6f15c53953..b86b325144 100644
--- a/src/resolve/resolved-dns-zone.c
+++ b/src/resolve/resolved-dns-zone.c
@@ -500,7 +500,7 @@ void dns_zone_item_conflict(DnsZoneItem *i) {
/* Withdraw the conflict item */
i->state = DNS_ZONE_ITEM_WITHDRAWN;
- dnssd_signal_conflict(i->scope->manager, dns_resource_key_name(i->rr->key));
+ (void) dnssd_signal_conflict(i->scope->manager, dns_resource_key_name(i->rr->key));
/* Maybe change the hostname */
if (manager_is_own_hostname(i->scope->manager, dns_resource_key_name(i->rr->key)) > 0)
diff --git a/src/resolve/resolved-dnssd.c b/src/resolve/resolved-dnssd.c
index 33d695a9ce..aed9c5c1cd 100644
--- a/src/resolve/resolved-dnssd.c
+++ b/src/resolve/resolved-dnssd.c
@@ -329,10 +329,13 @@ int dnssd_txt_item_new_from_data(const char *key, const void *data, const size_t
return 0;
}
-void dnssd_signal_conflict(Manager *manager, const char *name) {
+int dnssd_signal_conflict(Manager *manager, const char *name) {
DnssdService *s;
int r;
+ if (sd_bus_is_ready(manager->bus) <= 0)
+ return 0;
+
HASHMAP_FOREACH(s, manager->dnssd_services) {
if (s->withdrawn)
continue;
@@ -343,22 +346,20 @@ void dnssd_signal_conflict(Manager *manager, const char *name) {
s->withdrawn = true;
r = sd_bus_path_encode("/org/freedesktop/resolve1/dnssd", s->name, &path);
- if (r < 0) {
- log_error_errno(r, "Can't get D-BUS object path: %m");
- return;
- }
+ if (r < 0)
+ return log_error_errno(r, "Can't get D-BUS object path: %m");
r = sd_bus_emit_signal(manager->bus,
path,
"org.freedesktop.resolve1.DnssdService",
"Conflicted",
NULL);
- if (r < 0) {
- log_error_errno(r, "Cannot emit signal: %m");
- return;
- }
+ if (r < 0)
+ return log_error_errno(r, "Cannot emit signal: %m");
break;
}
}
+
+ return 0;
}
diff --git a/src/resolve/resolved-dnssd.h b/src/resolve/resolved-dnssd.h
index 8fe755687e..d020bb531c 100644
--- a/src/resolve/resolved-dnssd.h
+++ b/src/resolve/resolved-dnssd.h
@@ -58,4 +58,4 @@ int dnssd_load(Manager *manager);
int dnssd_txt_item_new_from_string(const char *key, const char *value, DnsTxtItem **ret_item);
int dnssd_txt_item_new_from_data(const char *key, const void *value, const size_t size, DnsTxtItem **ret_item);
int dnssd_update_rrs(DnssdService *s);
-void dnssd_signal_conflict(Manager *manager, const char *name);
+int dnssd_signal_conflict(Manager *manager, const char *name);