mirror of
https://github.com/systemd/systemd.git
synced 2025-01-11 09:18:07 +03:00
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 3e85ec0721
.
Fixes #8719.
This commit is contained in:
parent
3ac2e8fe17
commit
0630eb1bcc
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user