aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2019-02-05 07:45:18 -0600
committerRob Landley <rob@landley.net>2019-02-05 07:45:18 -0600
commit7a3f339fd722bf9cc13fff1fde7bd98bfed9f67f (patch)
tree1909d61e682b8207e61ab276d37733c9f15fcb52 /toys
parentb56f9f33fa1c9361f0f12b0179965602cb2363aa (diff)
downloadtoybox-7a3f339fd722bf9cc13fff1fde7bd98bfed9f67f.tar.gz
Fix server mode and make request timeout 3 tries of 3 seconds (9 sec total).
Diffstat (limited to 'toys')
-rw-r--r--toys/pending/sntp.c8
1 files 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<<TT.r)*1000;
@@ -176,7 +176,7 @@ void sntp_main(void)
now = millitime();
strike = xrecvwait(fd, toybuf, sizeof(toybuf), &sa, then-now);
if (strike<1) {
- if (!(FLAG(S)||FLAG(m)||FLAG(D)||FLAG(d)) && ++tries>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 {