diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-03-29 23:15:56 +0900 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-03-29 16:15:56 +0200 |
commit | 3e85ec072180b6fbec82d715186985536859a29d (patch) | |
tree | 186a104e5762803ecd5e079b89ab8764f69c0a57 | |
parent | 56fbd7187a5af44a90c258fbeb1f17114f226bb3 (diff) | |
download | systemd-3e85ec072180b6fbec82d715186985536859a29d.tar.gz |
timesync: on network event do not establish connection when NTP servers are not changed (#8611)
Fixes #8603.
-rw-r--r-- | src/timesync/timesyncd-manager.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c index a6d336c461..7743036023 100644 --- a/src/timesync/timesyncd-manager.c +++ b/src/timesync/timesyncd-manager.c @@ -1006,6 +1006,7 @@ static int manager_network_read_link_servers(Manager *m) { _cleanup_strv_free_ char **ntp = NULL; ServerName *n, *nx; char **i; + bool changed = false; int r; assert(m); @@ -1031,14 +1032,18 @@ static int manager_network_read_link_servers(Manager *m) { r = server_name_new(m, NULL, SERVER_LINK, *i); if (r < 0) goto clear; + + changed = true; } } LIST_FOREACH_SAFE(names, n, nx, m->link_servers) - if (n->marked) + if (n->marked) { server_name_free(n); + changed = true; + } - return 0; + return changed; clear: manager_flush_server_names(m, SERVER_LINK); @@ -1047,14 +1052,14 @@ clear: static int manager_network_event_handler(sd_event_source *s, int fd, uint32_t revents, void *userdata) { Manager *m = userdata; - bool connected, online; + bool changed, connected, online; int r; assert(m); sd_network_monitor_flush(m->network_monitor); - manager_network_read_link_servers(m); + changed = !!manager_network_read_link_servers(m); /* check if the machine is online */ online = network_is_online(); @@ -1066,7 +1071,7 @@ static int manager_network_event_handler(sd_event_source *s, int fd, uint32_t re log_info("No network connectivity, watching for changes."); manager_disconnect(m); - } else if (!connected && online) { + } else if (!connected && online && changed) { log_info("Network configuration changed, trying to establish connection."); if (m->current_server_address) |