mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
timesync: several cleanups (#39220)
Prompted by the logs provided at https://github.com/systemd/systemd/issues/36498#issuecomment-3369227155.
This commit is contained in:
@@ -886,16 +886,16 @@ static int bus_socket_inotify_setup(sd_bus *b) {
|
||||
}
|
||||
|
||||
wd = inotify_add_watch(b->inotify_fd, prefix, IN_DELETE_SELF|IN_MOVE_SELF|IN_ATTRIB|IN_CREATE|IN_MOVED_TO|IN_DONT_FOLLOW);
|
||||
log_debug("Added inotify watch for %s on bus %s: %i", prefix, strna(b->description), wd);
|
||||
|
||||
if (wd < 0) {
|
||||
if (IN_SET(errno, ENOENT, ELOOP))
|
||||
break; /* This component doesn't exist yet, or the path contains a cyclic symlink right now */
|
||||
|
||||
r = log_debug_errno(errno, "Failed to add inotify watch on %s: %m", empty_to_root(prefix));
|
||||
goto fail;
|
||||
} else
|
||||
} else {
|
||||
log_debug("Added inotify watch %i for %s on bus %s.", wd, prefix, strna(b->description));
|
||||
new_watches[n++] = wd;
|
||||
}
|
||||
|
||||
/* Check if this is possibly a symlink. If so, let's follow it and watch it too. */
|
||||
r = readlink_malloc(prefix, &destination);
|
||||
|
||||
@@ -911,7 +911,7 @@ void manager_disconnect(Manager *m) {
|
||||
(void) sd_notify(false, "STATUS=Idle.");
|
||||
}
|
||||
|
||||
void manager_flush_server_names(Manager *m, ServerType t) {
|
||||
void manager_flush_server_names(Manager *m, ServerType t) {
|
||||
assert(m);
|
||||
|
||||
if (t == SERVER_SYSTEM)
|
||||
@@ -966,19 +966,19 @@ Manager* manager_free(Manager *m) {
|
||||
return mfree(m);
|
||||
}
|
||||
|
||||
static int manager_network_read_link_servers(Manager *m) {
|
||||
static bool manager_network_read_link_servers(Manager *m) {
|
||||
_cleanup_strv_free_ char **ntp = NULL;
|
||||
bool changed = false;
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
|
||||
bool existing = m->link_servers;
|
||||
|
||||
r = sd_network_get_ntp(&ntp);
|
||||
if (r < 0 && r != -ENODATA) {
|
||||
if (r == -ENOMEM)
|
||||
log_oom();
|
||||
else
|
||||
log_debug_errno(r, "Failed to get link NTP servers: %m");
|
||||
if (r < 0) {
|
||||
if (!IN_SET(r, -ENOENT, -ENODATA))
|
||||
log_error_errno(r, "Failed to get link NTP servers: %m");
|
||||
goto clear;
|
||||
}
|
||||
|
||||
@@ -1025,7 +1025,7 @@ static int manager_network_read_link_servers(Manager *m) {
|
||||
|
||||
clear:
|
||||
manager_flush_server_names(m, SERVER_LINK);
|
||||
return r;
|
||||
return existing; /* return true if there were existing servers. */
|
||||
}
|
||||
|
||||
static bool manager_is_connected(Manager *m) {
|
||||
@@ -1043,7 +1043,6 @@ static int manager_network_event_handler(sd_event_source *s, int fd, uint32_t re
|
||||
|
||||
sd_network_monitor_flush(m->network_monitor);
|
||||
|
||||
/* When manager_network_read_link_servers() failed, we assume that the servers are changed. */
|
||||
changed = manager_network_read_link_servers(m);
|
||||
|
||||
/* check if the machine is online */
|
||||
|
||||
Reference in New Issue
Block a user