diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2011-04-07 01:45:20 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-04-07 01:45:20 +0200 |
commit | 8e23fafadee75bbe275bb795d0b2c2121dad93e7 (patch) | |
tree | 6fd7c774e74a7e62a359b44396507f7affc79f7a /networking/ntpd.c | |
parent | c0644cac0d430a2925920aec6820dd103cdf145f (diff) | |
download | busybox-w32-8e23fafadee75bbe275bb795d0b2c2121dad93e7.tar.gz busybox-w32-8e23fafadee75bbe275bb795d0b2c2121dad93e7.tar.bz2 busybox-w32-8e23fafadee75bbe275bb795d0b2c2121dad93e7.zip |
ntpd: decrease ntpd -q "no response" timeout to 10 sec
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/ntpd.c')
-rw-r--r-- | networking/ntpd.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/networking/ntpd.c b/networking/ntpd.c index 3ed05ba29..ba2950d8f 100644 --- a/networking/ntpd.c +++ b/networking/ntpd.c | |||
@@ -238,6 +238,8 @@ enum { | |||
238 | OPT_p = (1 << 5), | 238 | OPT_p = (1 << 5), |
239 | OPT_S = (1 << 6), | 239 | OPT_S = (1 << 6), |
240 | OPT_l = (1 << 7) * ENABLE_FEATURE_NTPD_SERVER, | 240 | OPT_l = (1 << 7) * ENABLE_FEATURE_NTPD_SERVER, |
241 | /* We hijack some bits for other purposes */ | ||
242 | OPT_qq = (1 << 8), | ||
241 | }; | 243 | }; |
242 | 244 | ||
243 | struct globals { | 245 | struct globals { |
@@ -1930,15 +1932,18 @@ static NOINLINE void ntp_init(char **argv) | |||
1930 | setpriority(PRIO_PROCESS, 0, -15); | 1932 | setpriority(PRIO_PROCESS, 0, -15); |
1931 | 1933 | ||
1932 | /* If network is up, syncronization occurs in ~10 seconds. | 1934 | /* If network is up, syncronization occurs in ~10 seconds. |
1933 | * We give "ntpd -q" a full minute to finish, then we exit. | 1935 | * We give "ntpd -q" 10 seconds to get first reply, |
1936 | * then another 50 seconds to finish syncing. | ||
1934 | * | 1937 | * |
1935 | * I tested ntpd 4.2.6p1 and apparently it never exits | 1938 | * I tested ntpd 4.2.6p1 and apparently it never exits |
1936 | * (will try forever), but it does not feel right. | 1939 | * (will try forever), but it does not feel right. |
1937 | * The goal of -q is to act like ntpdate: set time | 1940 | * The goal of -q is to act like ntpdate: set time |
1938 | * after a reasonably small period of polling, or fail. | 1941 | * after a reasonably small period of polling, or fail. |
1939 | */ | 1942 | */ |
1940 | if (opts & OPT_q) | 1943 | if (opts & OPT_q) { |
1941 | alarm(60); | 1944 | option_mask32 |= OPT_qq; |
1945 | alarm(10); | ||
1946 | } | ||
1942 | 1947 | ||
1943 | bb_signals(0 | 1948 | bb_signals(0 |
1944 | | (1 << SIGTERM) | 1949 | | (1 << SIGTERM) |
@@ -2065,6 +2070,15 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv) | |||
2065 | #endif | 2070 | #endif |
2066 | for (; nfds != 0 && j < i; j++) { | 2071 | for (; nfds != 0 && j < i; j++) { |
2067 | if (pfd[j].revents /* & (POLLIN|POLLERR)*/) { | 2072 | if (pfd[j].revents /* & (POLLIN|POLLERR)*/) { |
2073 | /* | ||
2074 | * At init, alarm was set to 10 sec. | ||
2075 | * Now we did get a reply. | ||
2076 | * Increase timeout to 50 seconds to finish syncing. | ||
2077 | */ | ||
2078 | if (option_mask32 & OPT_qq) { | ||
2079 | option_mask32 &= ~OPT_qq; | ||
2080 | alarm(50); | ||
2081 | } | ||
2068 | nfds--; | 2082 | nfds--; |
2069 | recv_and_process_peer_pkt(idx2peer[j]); | 2083 | recv_and_process_peer_pkt(idx2peer[j]); |
2070 | gettime1900d(); /* sets G.cur_time */ | 2084 | gettime1900d(); /* sets G.cur_time */ |