From: Danny Mayer Date: Wed, 2 Mar 2005 19:37:49 +0000 (-0500) Subject: Fix to ignore 0 or less readlengths after the first one X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f9e60f001e745cf4a01fc953afd9dcb4bcf04e39;p=thirdparty%2Fntp.git Fix to ignore 0 or less readlengths after the first one bk: 4226160dXQxAS6kWBdf5U-pZBLdsGA --- diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index 08b522a426..2614657761 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -1829,6 +1829,15 @@ input_handler( ) { + /* + * List of fd's to skip the read + * We don't really expect to have this many + * refclocks on a system + */ +#define MAXSKIPS 20 + int skiplist[MAXSKIPS]; + int totskips; + isc_boolean_t skip; int nonzeroreads; int buflen; register int i, n; @@ -1843,6 +1852,15 @@ input_handler( int select_count = 0; static int handler_count = 0; + /* + * Initialize the skip list + */ + for (i = 0; i 0) { @@ -1869,10 +1892,6 @@ input_handler( ++select_count; ++handler_pkts; -#ifdef REFCLOCK - /* - * Check out the reference clocks first, if any - */ if (refio != 0) { register struct refclockio *rp; @@ -1880,6 +1899,20 @@ input_handler( for (rp = refio; rp != 0; rp = rp->next) { fd = rp->fd; + skip = ISC_FALSE; + /* Check for skips */ + for (i = 0; i < totskips; i++) + { + if (fd == skiplist[i]) + { + skip = ISC_TRUE; + break; + } + } + /* fd was on skip list */ + if (skip == ISC_TRUE) + continue; + if (FD_ISSET(fd, &fds)) { n--; @@ -1891,6 +1924,11 @@ input_handler( packets_dropped++; if (buflen > 0) nonzeroreads++; + else + { + skiplist[totskips] = fd; + totskips++; + } continue; /* Keep reading until drained */ } @@ -1908,11 +1946,17 @@ input_handler( netsyslog(LOG_ERR, "clock read fd %d: %m", fd); } freerecvbuf(rb); - break; + skiplist[totskips] = fd; + totskips++; + continue; } if(buflen > 0) nonzeroreads++; - + else + { + skiplist[totskips] = fd; + totskips++; + } /* * Got one. Mark how and when it got here, * put it on the full list and do