On Sun, Nov 7, 2010 at 12:56 AM, Denys Vlasenko <[email protected]> wrote: > On Sun, Nov 7, 2010 at 12:40 AM, Rob Landley <[email protected]> wrote: >> I keep bookmarking things like this: >> >> http://lists.busybox.net/pipermail/busybox/2010-October/073518.html >> >> Which was a 30 second fix: all those #ifdefs could be if() statements. I >> realize you don't see this is a problem, but I do. > > In this case, I agree with you. Ping me about it, and I'll fix it. > > Er.... I did *not* apply it in that form, I decided to not create > a new CONFIG_foo for this. > > So there's nothing to fix in this case.
Here's the change as it went into git: commit d678257c26e0993efc48ac4433d153e1e9dfc954 Author: Denys Vlasenko <[email protected]> Date: Mon Oct 4 01:20:44 2010 +0200 ntpd: allow peer-less (standalone stratum 1 server) operation Based on patch by Jean-Christophe Dubois ([email protected]) function old new delta ntp_init 384 399 +15 recv_and_process_client_pkt 469 480 +11 Signed-off-by: Denys Vlasenko <[email protected]> diff --git a/networking/ntpd.c b/networking/ntpd.c index 6707e9b..ca4afa0 100644 --- a/networking/ntpd.c +++ b/networking/ntpd.c @@ -1765,6 +1765,10 @@ recv_and_process_client_pkt(void /*int fd*/) /* this time was obtained between poll() and recv() */ msg.m_rectime = d_to_lfp(G.cur_time); msg.m_xmttime = d_to_lfp(gettime1900d()); /* this instant */ + if (G.peer_cnt == 0) { + /* we have no peers: "stratum 1 server" mode. reftime = our own time */ + G.reftime = G.cur_time; + } msg.m_reftime = d_to_lfp(G.reftime); msg.m_orgtime = query_xmttime; msg.m_rootdelay = d_to_sfp(G.rootdelay); @@ -1902,8 +1906,13 @@ static NOINLINE void ntp_init(char **argv) bb_show_usage(); // if (opts & OPT_x) /* disable stepping, only slew is allowed */ // G.time_was_stepped = 1; - while (peers) - add_peers(llist_pop(&peers)); + if (peers) { + while (peers) + add_peers(llist_pop(&peers)); + } else { + /* -l but no peers: "stratum 1 server" mode */ + G.stratum = 1; + } if (!(opts & OPT_n)) { bb_daemonize_or_rexec(DAEMON_DEVNULL_STDIO, argv); logmode = LOGMODE_NONE; -- vda _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
