diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-04-18 03:56:12 +0900 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-04-17 20:56:12 +0200 |
commit | 0630eb1bcc6a4c2d05e57f58bea77da36697530a (patch) | |
tree | 94cd68b830f0b625dee781199331db9be52c4838 /src/timesync | |
parent | 3ac2e8fe178ed5ed5eda003901ead6731fbbb066 (diff) | |
download | systemd-0630eb1bcc6a4c2d05e57f58bea77da36697530a.tar.gz |
timesync: establish connection when network become online and the manager is not connected yet (#8727)
This also introduces `manager_is_connected()` helper function, which
returns true when the manager is sending a request, resolving a server
name, or in a poll interval.
Follow-up for 3e85ec072180b6fbec82d715186985536859a29d.
Fixes #8719.
Diffstat (limited to 'src/timesync')
-rw-r--r-- | src/timesync/timesyncd-manager.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c index 5b26baf39b..c5721a5752 100644 --- a/src/timesync/timesyncd-manager.c +++ b/src/timesync/timesyncd-manager.c @@ -1037,6 +1037,12 @@ clear: return r; } +static bool manager_is_connected(Manager *m) { + /* Return true when the manager is sending a request, resolving a server name, or + * in a poll interval. */ + return m->server_socket >= 0 || m->resolve_query || m->event_timer; +} + static int manager_network_event_handler(sd_event_source *s, int fd, uint32_t revents, void *userdata) { Manager *m = userdata; bool changed, connected, online; @@ -1052,13 +1058,13 @@ static int manager_network_event_handler(sd_event_source *s, int fd, uint32_t re online = network_is_online(); /* check if the client is currently connected */ - connected = m->server_socket >= 0 || m->resolve_query || m->exhausted_servers; + connected = manager_is_connected(m); if (connected && !online) { log_info("No network connectivity, watching for changes."); manager_disconnect(m); - } else if (!connected && online && changed) { + } else if ((!connected || changed) && online) { log_info("Network configuration changed, trying to establish connection."); if (m->current_server_address) |