From: Dave Hart Date: Fri, 26 Feb 2010 22:59:36 +0000 (+0000) Subject: ntp_config.c: X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=22cb46dd89fb9b734a04f432953919989ffff798;p=thirdparty%2Fntp.git ntp_config.c: Dr. Mills doesn't like depending on && not evaluating right side if left is false. ntp_proto.c: timeout demobilizations don't seem to be working for preemptibles. bk: 4b885258aOgRK6SKZyXjfSnoZvWRkA --- diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c index 611be49dbc..98059d4ae3 100644 --- a/ntpd/ntp_config.c +++ b/ntpd/ntp_config.c @@ -3735,11 +3735,13 @@ config_unpeers( DPRINTF(1, ("searching for %s\n", stoa(&peeraddr))); peer = NULL; - do { + while (TRUE) { peer = findexistingpeer(&peeraddr, NULL, peer, -1); - if (peer != NULL && (FLAG_CONFIG & peer->flags)) + if (NULL == peer) break; - } while (peer != NULL); + if (FLAG_CONFIG & peer->flags) + break; + } if (peer != NULL) { msyslog(LOG_INFO, "unpeered %s", @@ -3806,11 +3808,13 @@ unpeer_name_resolved( memcpy(&peeraddr, res->ai_addr, res->ai_addrlen); DPRINTF(1, ("searching for peer %s\n", stoa(&peeraddr))); peer = NULL; - do { + while (TRUE) { peer = findexistingpeer(&peeraddr, NULL, peer, -1); - if (peer != NULL && (FLAG_CONFIG & peer->flags)) + if (NULL == peer) break; - } while (peer != NULL); + if (FLAG_CONFIG & peer->flags) + break; + } if (peer != NULL) { fam_spec = (AF_INET6 == af) diff --git a/ntpd/ntp_proto.c b/ntpd/ntp_proto.c index 7666ed389b..cabdcd746b 100644 --- a/ntpd/ntp_proto.c +++ b/ntpd/ntp_proto.c @@ -202,13 +202,13 @@ transmit( * growth in associations if the system clock or network quality * result in survivor count dipping below sys_minclock often. * This was observed testing with pool, where sys_maxclock == 12 - * resulted in 34 associations without the hard limit. A + * resulted in 60 associations without the hard limit. A * similar hard limit on manycastclient ephemeral associations * may be appropriate. */ if (peer->cast_flags & MDF_POOL) { peer->outdate = current_time; - if (/* peer_associations < 2 * sys_maxclock && */ + if ((peer_associations <= 2 * sys_maxclock) && (peer_associations < sys_maxclock || sys_survivors < sys_minclock)) pool_xmit(peer); @@ -252,12 +252,12 @@ transmit( /* * Here the peer is reachable. Send a burst if * enabled and the peer is fit. Reset unreach - * for configured associations. Preemptible and - * ephemeral associations have unreach reset if - * they are survivors in clock_select(). + * for persistent associations. Unreach is also + * reset for survivors in clock_select(). */ hpoll = sys_poll; - if (peer->flags & FLAG_CONFIG) + if ((peer->flags & FLAG_CONFIG) && !(peer->flags + & FLAG_PREEMPT)) peer->unreach = 0; if ((peer->flags & FLAG_BURST) && peer->retry == 0 && !peer_unfit(peer)) @@ -265,16 +265,25 @@ transmit( } /* - * Watch for timeout. If preemptible, toss the rascal; + * Watch for timeout. If ephemeral, toss the rascal; * otherwise, bump the poll interval. Note the * poll_update() routine will clamp it to maxpoll. + * If preemptible and we have more peers than maxclock, + * and this peer has the minimum score of preemptibles, + * demobilize. */ if (peer->unreach >= NTP_UNREACH) { hpoll++; - if (!(peer->flags & FLAG_CONFIG) && - (!(peer->flags & FLAG_PREEMPT) || - (peer_associations > sys_maxclock && - score_all(peer)))) { + /* ephemeral: no FLAG_CONFIG nor FLAG_PREEMPT */ + if (!(peer->flags & (FLAG_CONFIG | FLAG_PREEMPT))) { + report_event(PEVNT_RESTART, peer, "timeout"); + peer_clear(peer, "TIME"); + unpeer(peer); + return; + } + if ((peer->flags & FLAG_PREEMPT) && + (peer_associations > sys_maxclock) && + score_all(peer)) { report_event(PEVNT_RESTART, peer, "timeout"); peer_clear(peer, "TIME"); unpeer(peer); @@ -3462,7 +3471,7 @@ pool_xmit( pool->sent++; pool->throttle += (1 << pool->minpoll) - 2; #ifdef DEBUG - msyslog(LOG_INFO, "transmit: at %ld %s->%s pool\n", /* !!!!! */ + msyslog(LOG_NOTICE, "transmit: at %ld %s->%s pool\n", /* !!!!! */ current_time, latoa(lcladr), stoa(rmtadr)); if (debug) printf("transmit: at %ld %s->%s pool\n",