diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/resolve/resolved-bus.c | 33 | ||||
-rw-r--r-- | src/resolve/resolved-dns-zone.c | 14 | ||||
-rw-r--r-- | src/resolve/resolved-dns-zone.h | 2 | ||||
-rw-r--r-- | src/resolve/resolved-manager.c | 10 | ||||
-rw-r--r-- | src/resolve/resolved-manager.h | 5 |
5 files changed, 64 insertions, 0 deletions
diff --git a/src/resolve/resolved-bus.c b/src/resolve/resolved-bus.c index 6a3343e000..cfe12d3bed 100644 --- a/src/resolve/resolved-bus.c +++ b/src/resolve/resolved-bus.c @@ -638,6 +638,28 @@ static int on_bus_retry(sd_event_source *s, usec_t usec, void *userdata) { return 0; } +static int match_prepare_for_sleep(sd_bus *bus, sd_bus_message *message, void *userdata, sd_bus_error *ret_error) { + Manager *m = userdata; + int b, r; + + assert(bus); + assert(bus); + + r = sd_bus_message_read(message, "b", &b); + if (r < 0) { + log_debug("Failed to parse PrepareForSleep signal: %s", strerror(-r)); + return 0; + } + + if (b) + return 0; + + log_debug("Coming back from suspend, verifying all RRs..."); + + manager_verify_all(m); + return 0; +} + int manager_connect_bus(Manager *m) { int r; @@ -681,5 +703,16 @@ int manager_connect_bus(Manager *m) { return r; } + r = sd_bus_add_match(m->bus, &m->prepare_for_sleep_slot, + "type='signal'," + "sender='org.freedesktop.login1'," + "interface='org.freedesktop.login1.Manager'," + "member='PrepareForSleep'," + "path='/org/freedesktop/login1'", + match_prepare_for_sleep, + m); + if (r < 0) + log_error("Failed to add match for PrepareForSleep: %s", strerror(-r)); + return 0; } diff --git a/src/resolve/resolved-dns-zone.c b/src/resolve/resolved-dns-zone.c index d96ddd270c..5f250e7ca3 100644 --- a/src/resolve/resolved-dns-zone.c +++ b/src/resolve/resolved-dns-zone.c @@ -625,3 +625,17 @@ int dns_zone_verify_conflicts(DnsZone *zone, DnsResourceKey *key) { return c; } + +void dns_zone_verify_all(DnsZone *zone) { + DnsZoneItem *i; + Iterator iterator; + + assert(zone); + + HASHMAP_FOREACH(i, zone->by_key, iterator) { + DnsZoneItem *j; + + LIST_FOREACH(by_key, j, i) + dns_zone_item_verify(j); + } +} diff --git a/src/resolve/resolved-dns-zone.h b/src/resolve/resolved-dns-zone.h index 37fdafe040..482df2f15f 100644 --- a/src/resolve/resolved-dns-zone.h +++ b/src/resolve/resolved-dns-zone.h @@ -74,3 +74,5 @@ void dns_zone_item_ready(DnsZoneItem *i); int dns_zone_check_conflicts(DnsZone *zone, DnsResourceRecord *rr); int dns_zone_verify_conflicts(DnsZone *zone, DnsResourceKey *key); + +void dns_zone_verify_all(DnsZone *zone); diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c index a93f4a597f..1d33c2ae19 100644 --- a/src/resolve/resolved-manager.c +++ b/src/resolve/resolved-manager.c @@ -554,6 +554,7 @@ Manager *manager_free(Manager *m) { manager_llmnr_stop(m); + sd_bus_slot_unref(m->prepare_for_sleep_slot); sd_event_source_unref(m->bus_retry_event_source); sd_bus_unref(m->bus); @@ -1722,6 +1723,15 @@ DnsScope* manager_find_scope(Manager *m, DnsPacket *p) { return NULL; } +void manager_verify_all(Manager *m) { + DnsScope *s; + + assert(m); + + LIST_FOREACH(scopes, s, m->dns_scopes) + dns_zone_verify_all(&s->zone); +} + static const char* const support_table[_SUPPORT_MAX] = { [SUPPORT_NO] = "no", [SUPPORT_YES] = "yes", diff --git a/src/resolve/resolved-manager.h b/src/resolve/resolved-manager.h index f960bc2f1e..f8cb91c330 100644 --- a/src/resolve/resolved-manager.h +++ b/src/resolve/resolved-manager.h @@ -108,6 +108,9 @@ struct Manager { /* Watch the system hostname */ int hostname_fd; sd_event_source *hostname_event_source; + + /* Watch for system suspends */ + sd_bus_slot *prepare_for_sleep_slot; }; /* Manager */ @@ -146,6 +149,8 @@ int manager_next_hostname(Manager *m); bool manager_our_packet(Manager *m, DnsPacket *p); DnsScope* manager_find_scope(Manager *m, DnsPacket *p); +void manager_verify_all(Manager *m); + DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free); #define EXTRA_CMSG_SPACE 1024 |