From 7a3f339fd722bf9cc13fff1fde7bd98bfed9f67f Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 5 Feb 2019 07:45:18 -0600 Subject: Fix server mode and make request timeout 3 tries of 3 seconds (9 sec total). --- toys/pending/sntp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/toys/pending/sntp.c b/toys/pending/sntp.c index b85b9dce..bd2f75ca 100644 --- a/toys/pending/sntp.c +++ b/toys/pending/sntp.c @@ -153,7 +153,7 @@ void sntp_main(void) // daemon and oneshot modes send a packet each time through outer loop else { - then = (now = millitime()) + 4000; + then = (now = millitime()) + 3000; if (FLAG(d) || FLAG(D)) then = now + (1<3) + if (!(FLAG(S)||FLAG(m)||FLAG(D)||FLAG(d)) && ++tries == 3) error_exit("no reply from %s", *toys.optargs); break; } @@ -209,8 +209,8 @@ void sntp_main(void) strcpy(buf+12, "LOCL"); pktime[6+3] = pktime[5]; // send back reference time they sent us // everything else is current time - pktime[6+2] = pktime[6+4] = pktime[6+5] = lunchtime(0, 0); - xsendto(fd, toybuf, 48, (void *)&sa); + pktime[6+2] = pktime[6+4] = pktime[6+5] = SWAP_BE64(lunchtime(0, 0)); + xsendto(fd, buf, 48, (void *)&sa); // Got a time packet from a recognized server } else { -- cgit v1.2.3