From 11b2780ea60acd359bda7923e5d4460b3835f053 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Tue, 5 Feb 2019 08:14:40 -0600 Subject: Fix server loop timeout logic. --- toys/pending/sntp.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/toys/pending/sntp.c b/toys/pending/sntp.c index bd2f75ca..8a061584 100644 --- a/toys/pending/sntp.c +++ b/toys/pending/sntp.c @@ -148,32 +148,31 @@ void sntp_main(void) // loop sending/receiving packets for (;;) { + now = millitime(); + // Figure out if we're in server and multicast modes don't poll if (FLAG(m) || FLAG(S)) then = -1; // daemon and oneshot modes send a packet each time through outer loop else { - then = (now = millitime()) + 3000; - + then = now + 3000; if (FLAG(d) || FLAG(D)) then = now + (1<ai_addr); } // Loop receiving packets until it's time to send the next one. - while (then>0 && now0 && then<(now = millitime())) break;; strike = xrecvwait(fd, toybuf, sizeof(toybuf), &sa, then-now); if (strike<1) { if (!(FLAG(S)||FLAG(m)||FLAG(D)||FLAG(d)) && ++tries == 3) -- cgit v1.2.3