summaryrefslogtreecommitdiff
path: root/src/timesync
diff options
context:
space:
mode:
Diffstat (limited to 'src/timesync')
-rw-r--r--src/timesync/timesyncd-conf.c1
-rw-r--r--src/timesync/timesyncd-manager.c26
-rw-r--r--src/timesync/timesyncd-manager.h2
-rw-r--r--src/timesync/timesyncd-server.h2
-rw-r--r--src/timesync/timesyncd.c2
-rw-r--r--src/timesync/timesyncd.conf.in7
6 files changed, 20 insertions, 20 deletions
diff --git a/src/timesync/timesyncd-conf.c b/src/timesync/timesyncd-conf.c
index be1f4bb151..df4d89a620 100644
--- a/src/timesync/timesyncd-conf.c
+++ b/src/timesync/timesyncd-conf.c
@@ -19,7 +19,6 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
-#include "in-addr-util.h"
#include "timesyncd-manager.h"
#include "timesyncd-server.h"
diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c
index 73ac7eecbf..88e9cf98ed 100644
--- a/src/timesync/timesyncd-manager.c
+++ b/src/timesync/timesyncd-manager.c
@@ -21,21 +21,15 @@
#include <stdlib.h>
#include <errno.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <string.h>
#include <time.h>
#include <math.h>
-#include <arpa/inet.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <sys/timerfd.h>
#include <sys/timex.h>
#include <sys/socket.h>
#include <resolv.h>
-#include <sys/prctl.h>
#include <sys/types.h>
-#include <grp.h>
#include "missing.h"
#include "util.h"
@@ -45,13 +39,8 @@
#include "list.h"
#include "ratelimit.h"
#include "strv.h"
-#include "conf-parser.h"
#include "sd-daemon.h"
-#include "event-util.h"
#include "network-util.h"
-#include "clock-util.h"
-#include "capability.h"
-#include "mkdir.h"
#include "timesyncd-conf.h"
#include "timesyncd-manager.h"
#include "time-util.h"
@@ -680,6 +669,16 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re
m->poll_interval_usec / USEC_PER_SEC, offset, delay, m->samples_jitter, m->drift_ppm,
spike ? " (ignored)" : "");
+ if (!m->good) {
+ _cleanup_free_ char *pretty = NULL;
+
+ m->good = true;
+
+ server_address_pretty(m->current_server_address, &pretty);
+ log_info("Synchronized to time server %s (%s).", strna(pretty), m->current_server_name->string);
+ sd_notifyf(false, "STATUS=Synchronized to time server %s (%s).", strna(pretty), m->current_server_name->string);
+ }
+
r = manager_arm_timer(m, m->poll_interval_usec);
if (r < 0)
return log_error_errno(r, "Failed to rearm timer: %m");
@@ -735,13 +734,14 @@ static int manager_begin(Manager *m) {
assert_return(m->current_server_name, -EHOSTUNREACH);
assert_return(m->current_server_address, -EHOSTUNREACH);
+ m->good = false;
m->missed_replies = NTP_MAX_MISSED_REPLIES;
if (m->poll_interval_usec == 0)
m->poll_interval_usec = NTP_POLL_INTERVAL_MIN_SEC * USEC_PER_SEC;
server_address_pretty(m->current_server_address, &pretty);
- log_debug("Using NTP server %s (%s).", strna(pretty), m->current_server_name->string);
- sd_notifyf(false, "STATUS=Using Time Server %s (%s).", strna(pretty), m->current_server_name->string);
+ log_debug("Connecting to time server %s (%s).", strna(pretty), m->current_server_name->string);
+ sd_notifyf(false, "STATUS=Connecting to time server %s (%s).", strna(pretty), m->current_server_name->string);
r = manager_clock_watch_setup(m);
if (r < 0)
diff --git a/src/timesync/timesyncd-manager.h b/src/timesync/timesyncd-manager.h
index c7efdc5dfb..090b2fcba8 100644
--- a/src/timesync/timesyncd-manager.h
+++ b/src/timesync/timesyncd-manager.h
@@ -25,7 +25,6 @@
#include "sd-resolve.h"
#include "sd-network.h"
#include "list.h"
-#include "socket-util.h"
#include "ratelimit.h"
typedef struct Manager Manager;
@@ -56,6 +55,7 @@ struct Manager {
int missed_replies;
uint64_t packet_count;
sd_event_source *event_timeout;
+ bool good;
/* last sent packet */
struct timespec trans_time_mon;
diff --git a/src/timesync/timesyncd-server.h b/src/timesync/timesyncd-server.h
index 243b44a0eb..18c44445e1 100644
--- a/src/timesync/timesyncd-server.h
+++ b/src/timesync/timesyncd-server.h
@@ -59,7 +59,7 @@ struct ServerName {
int server_address_new(ServerName *n, ServerAddress **ret, const union sockaddr_union *sockaddr, socklen_t socklen);
ServerAddress* server_address_free(ServerAddress *a);
static inline int server_address_pretty(ServerAddress *a, char **pretty) {
- return sockaddr_pretty(&a->sockaddr.sa, a->socklen, true, pretty);
+ return sockaddr_pretty(&a->sockaddr.sa, a->socklen, true, true, pretty);
}
int server_name_new(Manager *m, ServerName **ret, ServerType type,const char *string);
diff --git a/src/timesync/timesyncd.c b/src/timesync/timesyncd.c
index 2a73dac033..d69129ee03 100644
--- a/src/timesync/timesyncd.c
+++ b/src/timesync/timesyncd.c
@@ -21,10 +21,10 @@
#include "sd-event.h"
#include "sd-daemon.h"
-#include "mkdir.h"
#include "capability.h"
#include "clock-util.h"
#include "network-util.h"
+#include "signal-util.h"
#include "timesyncd-manager.h"
#include "timesyncd-conf.h"
diff --git a/src/timesync/timesyncd.conf.in b/src/timesync/timesyncd.conf.in
index fc3c6c49cf..b6a2ada273 100644
--- a/src/timesync/timesyncd.conf.in
+++ b/src/timesync/timesyncd.conf.in
@@ -5,10 +5,11 @@
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
-# You can override the directives in this file by creating files in
-# /etc/systemd/timesyncd.conf.d/*.conf.
+# Entries in this file show the compile time defaults.
+# You can change settings by editing this file.
+# Defaults can be restored by simply deleting this file.
#
-# See timesyncd.conf(5) for details
+# See timesyncd.conf(5) for details.
[Time]
#NTP=