1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-31 07:51:21 +03:00

resolved: verify all RRs when we come back from suspend

This commit is contained in:
Lennart Poettering 2014-08-06 16:59:48 +02:00
parent 82bd6dddc4
commit 902bb5d8ab
5 changed files with 64 additions and 0 deletions

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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",

View File

@ -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