aboutsummaryrefslogtreecommitdiff
path: root/networking/ntpd.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-01-07 11:51:13 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-01-07 11:51:13 +0100
commitae47335dc4b5b8e9e43a3936274d6875238f0763 (patch)
treefa43f7c0e3e8930fd2e657ba42521f02f68c73a0 /networking/ntpd.c
parent053ffeeeda923eb5e8c6f18d1d614d4f8d1de4a2 (diff)
downloadbusybox-w32-ae47335dc4b5b8e9e43a3936274d6875238f0763.tar.gz
busybox-w32-ae47335dc4b5b8e9e43a3936274d6875238f0763.tar.bz2
busybox-w32-ae47335dc4b5b8e9e43a3936274d6875238f0763.zip
ntpd: show at loglevel 2 and export in env current poll interval
function old new delta run_script 273 340 +67 ntpd_main 832 845 +13 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to '')
-rw-r--r--networking/ntpd.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/networking/ntpd.c b/networking/ntpd.c
index 038f2bded..c28d76891 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -689,7 +689,7 @@ send_query_to_peer(peer_t *p)
689static void run_script(const char *action) 689static void run_script(const char *action)
690{ 690{
691 char *argv[3]; 691 char *argv[3];
692 char *env1, *env2; 692 char *env1, *env2, *env3;
693 693
694 if (!G.script_name) 694 if (!G.script_name)
695 return; 695 return;
@@ -700,12 +700,14 @@ static void run_script(const char *action)
700 700
701 VERB1 bb_error_msg("executing '%s %s'", G.script_name, action); 701 VERB1 bb_error_msg("executing '%s %s'", G.script_name, action);
702 702
703 env1 = xasprintf("stratum=%u", G.stratum); 703 env1 = xasprintf("%s=%u", "stratum", G.stratum);
704 putenv(env1); 704 putenv(env1);
705 env2 = xasprintf("freq_drift_ppm=%ld", G.kernel_freq_drift); 705 env2 = xasprintf("%s=%ld", "freq_drift_ppm", G.kernel_freq_drift);
706 putenv(env2); 706 putenv(env2);
707 env3 = xasprintf("%s=%u", "poll_interval", 1 << G.poll_exp);
708 putenv(env3);
707 /* Other items of potential interest: selected peer, 709 /* Other items of potential interest: selected peer,
708 * rootdelay, reftime, rootdisp, refid, ntp_status, poll_exp, 710 * rootdelay, reftime, rootdisp, refid, ntp_status,
709 * last_update_offset, last_update_recv_time, discipline_jitter 711 * last_update_offset, last_update_recv_time, discipline_jitter
710 */ 712 */
711 713
@@ -713,12 +715,15 @@ static void run_script(const char *action)
713 * may take some time (seconds): */ 715 * may take some time (seconds): */
714 /*wait4pid(spawn(argv));*/ 716 /*wait4pid(spawn(argv));*/
715 spawn(argv); 717 spawn(argv);
716 G.last_script_run = G.cur_time;
717 718
718 unsetenv("stratum"); 719 unsetenv("stratum");
719 unsetenv("freq_drift_ppm"); 720 unsetenv("freq_drift_ppm");
721 unsetenv("poll_interval");
720 free(env1); 722 free(env1);
721 free(env2); 723 free(env2);
724 free(env3);
725
726 G.last_script_run = G.cur_time;
722} 727}
723 728
724static NOINLINE void 729static NOINLINE void
@@ -1897,7 +1902,7 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv)
1897 timeout++; /* (nextaction - G.cur_time) rounds down, compensating */ 1902 timeout++; /* (nextaction - G.cur_time) rounds down, compensating */
1898 1903
1899 /* Here we may block */ 1904 /* Here we may block */
1900 VERB2 bb_error_msg("poll %us, sockets:%u", timeout, i); 1905 VERB2 bb_error_msg("poll %us, sockets:%u, poll interval:%us", timeout, i, 1 << G.poll_exp);
1901 nfds = poll(pfd, i, timeout * 1000); 1906 nfds = poll(pfd, i, timeout * 1000);
1902 gettime1900d(); /* sets G.cur_time */ 1907 gettime1900d(); /* sets G.cur_time */
1903 if (nfds <= 0) { 1908 if (nfds <= 0) {