From 600809211ecf1b1c3f2b701f30e5f77e33f0348b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 6 May 2014 12:34:03 +0200 Subject: [PATCH] timesyncd: keep order of NTP servers --- src/timesync/timesyncd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/timesync/timesyncd.c b/src/timesync/timesyncd.c index 1237abb5421..1c0f113778e 100644 --- a/src/timesync/timesyncd.c +++ b/src/timesync/timesyncd.c @@ -935,7 +935,7 @@ static int manager_connect(Manager *m) { } static int manager_add_server(Manager *m, const char *server) { - ServerName *n; + ServerName *n, *tail; assert(m); assert(server); @@ -950,7 +950,12 @@ static int manager_add_server(Manager *m, const char *server) { return -ENOMEM; } - LIST_PREPEND(names, m->servers, n); + if (m->servers) { + LIST_FIND_TAIL(names, m->servers, tail); + LIST_INSERT_AFTER(names, m->servers, tail, n); + } else + LIST_PREPEND(names, m->servers, n); + return 0; }