mirror of https://github.com/mirror/busybox.git
ntpd: decrease ntpd -q "no response" timeout to 10 sec
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>1_19_stable
parent
c0644cac0d
commit
8e23fafade
|
@ -238,6 +238,8 @@ enum {
|
||||||
OPT_p = (1 << 5),
|
OPT_p = (1 << 5),
|
||||||
OPT_S = (1 << 6),
|
OPT_S = (1 << 6),
|
||||||
OPT_l = (1 << 7) * ENABLE_FEATURE_NTPD_SERVER,
|
OPT_l = (1 << 7) * ENABLE_FEATURE_NTPD_SERVER,
|
||||||
|
/* We hijack some bits for other purposes */
|
||||||
|
OPT_qq = (1 << 8),
|
||||||
};
|
};
|
||||||
|
|
||||||
struct globals {
|
struct globals {
|
||||||
|
@ -1930,15 +1932,18 @@ static NOINLINE void ntp_init(char **argv)
|
||||||
setpriority(PRIO_PROCESS, 0, -15);
|
setpriority(PRIO_PROCESS, 0, -15);
|
||||||
|
|
||||||
/* If network is up, syncronization occurs in ~10 seconds.
|
/* If network is up, syncronization occurs in ~10 seconds.
|
||||||
* We give "ntpd -q" a full minute to finish, then we exit.
|
* We give "ntpd -q" 10 seconds to get first reply,
|
||||||
|
* then another 50 seconds to finish syncing.
|
||||||
*
|
*
|
||||||
* I tested ntpd 4.2.6p1 and apparently it never exits
|
* I tested ntpd 4.2.6p1 and apparently it never exits
|
||||||
* (will try forever), but it does not feel right.
|
* (will try forever), but it does not feel right.
|
||||||
* The goal of -q is to act like ntpdate: set time
|
* The goal of -q is to act like ntpdate: set time
|
||||||
* after a reasonably small period of polling, or fail.
|
* after a reasonably small period of polling, or fail.
|
||||||
*/
|
*/
|
||||||
if (opts & OPT_q)
|
if (opts & OPT_q) {
|
||||||
alarm(60);
|
option_mask32 |= OPT_qq;
|
||||||
|
alarm(10);
|
||||||
|
}
|
||||||
|
|
||||||
bb_signals(0
|
bb_signals(0
|
||||||
| (1 << SIGTERM)
|
| (1 << SIGTERM)
|
||||||
|
@ -2065,6 +2070,15 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv)
|
||||||
#endif
|
#endif
|
||||||
for (; nfds != 0 && j < i; j++) {
|
for (; nfds != 0 && j < i; j++) {
|
||||||
if (pfd[j].revents /* & (POLLIN|POLLERR)*/) {
|
if (pfd[j].revents /* & (POLLIN|POLLERR)*/) {
|
||||||
|
/*
|
||||||
|
* At init, alarm was set to 10 sec.
|
||||||
|
* Now we did get a reply.
|
||||||
|
* Increase timeout to 50 seconds to finish syncing.
|
||||||
|
*/
|
||||||
|
if (option_mask32 & OPT_qq) {
|
||||||
|
option_mask32 &= ~OPT_qq;
|
||||||
|
alarm(50);
|
||||||
|
}
|
||||||
nfds--;
|
nfds--;
|
||||||
recv_and_process_peer_pkt(idx2peer[j]);
|
recv_and_process_peer_pkt(idx2peer[j]);
|
||||||
gettime1900d(); /* sets G.cur_time */
|
gettime1900d(); /* sets G.cur_time */
|
||||||
|
|
Loading…
Reference in New Issue