From: Dave Hart Date: Mon, 15 Feb 2010 23:19:19 +0000 (+0000) Subject: [Bug 1464] synchronization source wrong for refclocks ARCRON_MSF (27) X-Git-Tag: NTP_4_2_6P1_RC6~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=208e5ac623c916bed1c845edab19df702dc53819;p=thirdparty%2Fntp.git [Bug 1464] synchronization source wrong for refclocks ARCRON_MSF (27) and SHM (28). Correct Windows port's refclock_open() to return 0 on failure not -1. Correct CHU, dumbclock, and WWVB drivers to check for 0 returned from refclock_open() on failure. Correct "SIMUL=4 ./flock-build -1" to prioritize -1/--one. bk: 4b79d677nCM0cZM7QfOXPN2qtirktA --- diff --git a/ChangeLog b/ChangeLog index 8fe00f113..27cd1d595 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +--- + +* [Bug 1464] synchronization source wrong for refclocks ARCRON_MSF (27) + and SHM (28). +* Correct Windows port's refclock_open() to return 0 on failure not -1. +* Correct CHU, dumbclock, and WWVB drivers to check for 0 returned from + refclock_open() on failure. +* Correct "SIMUL=4 ./flock-build -1" to prioritize -1/--one. + --- (4.2.6p1-RC5) 2010/02/09 Released by Harlan Stenn diff --git a/flock-build b/flock-build index dbdf990a4..1756cc4a0 100755 --- a/flock-build +++ b/flock-build @@ -18,10 +18,15 @@ PARSE="--enable-parse-clocks" #PARSE= STD="--enable-simulator" -case "$SIMUL" in - '') PARALLEL_BUILDS=1 - ;; - *) PARALLEL_BUILDS=$SIMUL +case "$SIMUL::$FB_FIRSTONLY" in + ::*) + PARALLEL_BUILDS=1 + ;; + *::0) + PARALLEL_BUILDS=$SIMUL + ;; + *) + PARALLEL_BUILDS=1 esac case "$PARALLEL_BUILDS" in @@ -63,19 +68,19 @@ do [ -f .buildkey-$i ] && SKIPTHIS=1 case "$SKIPTHIS" in 1) - echo flock-build running on $i? check LIST, skipping - ;; - 0) - echo $i - echo $SIG > .buildkey-$i - case "1" in - 0) - ssh $i "cd $c_d ; ./build $SIG $PARSE $STD $BUILD_ARGS" & - ssh $i "cd $c_d ; ./build $SIG $PARSE $STD --without-crypto $BUILD_ARGS" & - ssh $i "cd $c_d ; ./build $SIG $STD --disable-all-clocks $BUILD_ARGS" & - ;; - 1) - cat > .flockbuild-$i-$SIG <<-ENDQUOT + echo flock-build running on $i? check LIST, skipping + ;; + 0) + echo $i + echo $SIG > .buildkey-$i + case "1" in + 0) + ssh $i "cd $c_d ; ./build $SIG $PARSE $STD $BUILD_ARGS" & + ssh $i "cd $c_d ; ./build $SIG $PARSE $STD --without-crypto $BUILD_ARGS" & + ssh $i "cd $c_d ; ./build $SIG $STD --disable-all-clocks $BUILD_ARGS" & + ;; + 1) + cat > .flockbuild-$i-$SIG <<-ENDQUOT #!/bin/sh # script uses job control and expects to be invoked @@ -114,10 +119,10 @@ do echo \`date -u '+%H:%M:%S'\` $i flock-build $c_d done. rm .buildkey-$i ENDQUOT - chmod +x .flockbuild-$i-$SIG - ssh -tt $i "$c_d/.flockbuild-$i-$SIG ; \ - rm $c_d/.flockbuild-$i-$SIG" 2>/dev/null & - esac + chmod +x .flockbuild-$i-$SIG + ssh -tt $i "$c_d/.flockbuild-$i-$SIG ; \ + rm $c_d/.flockbuild-$i-$SIG" 2>/dev/null & + esac esac done echo `date -u '+%H:%M:%S'` flock-build launched diff --git a/ntpd/ntp_control.c b/ntpd/ntp_control.c index 9ab9d1c5e..7ffeacb5a 100644 --- a/ntpd/ntp_control.c +++ b/ntpd/ntp_control.c @@ -401,8 +401,8 @@ static u_char clocktypes[] = { CTL_SST_TS_NTP, /* not used (24) */ CTL_SST_TS_NTP, /* not used (25) */ CTL_SST_TS_UHF, /* REFCLK_GPS_HP (26) */ - CTL_SST_TS_TELEPHONE, /* REFCLK_ARCRON_MSF (27) */ - CTL_SST_TS_TELEPHONE, /* REFCLK_SHM (28) */ + CTL_SST_TS_LF, /* REFCLK_ARCRON_MSF (27) */ + CTL_SST_TS_UHF, /* REFCLK_SHM (28) */ CTL_SST_TS_UHF, /* REFCLK_PALISADE (29) */ CTL_SST_TS_UHF, /* REFCLK_ONCORE (30) */ CTL_SST_TS_UHF, /* REFCLK_JUPITER (31) */ diff --git a/ntpd/ntp_refclock.c b/ntpd/ntp_refclock.c index 827529433..d299903a8 100644 --- a/ntpd/ntp_refclock.c +++ b/ntpd/ntp_refclock.c @@ -11,6 +11,7 @@ #include "ntp_tty.h" #include "ntp_refclock.h" #include "ntp_stdlib.h" +#include "ntp_assert.h" #include @@ -758,6 +759,7 @@ refclock_open( msyslog(LOG_ERR, "refclock_open %s: %m", dev); return (0); } + NTP_INSIST(fd != 0); if (!refclock_setup(fd, speed, lflags)) { close(fd); return (0); @@ -769,6 +771,7 @@ refclock_open( return (fd); } + /* * refclock_setup - initialize terminal interface structure */ @@ -1311,7 +1314,7 @@ refclock_pps( /* * Convert to signed fraction offset and stuff in median filter. */ - pp->lastrec.l_ui = ap->ts.tv_sec + JAN_1970; + pp->lastrec.l_ui = (u_int32)ap->ts.tv_sec + JAN_1970; dtemp = ap->ts.tv_nsec / 1e9; pp->lastrec.l_uf = (u_int32)(dtemp * FRAC); if (dtemp > .5) diff --git a/ntpd/refclock_chu.c b/ntpd/refclock_chu.c index de3488631..ca14dc600 100644 --- a/ntpd/refclock_chu.c +++ b/ntpd/refclock_chu.c @@ -500,7 +500,7 @@ chu_start( snprintf(device, sizeof(device), DEVICE, unit); fd = refclock_open(device, SPEED232, LDISC_RAW); #endif /* HAVE_AUDIO */ - if (fd < 0) + if (fd <= 0) return (0); /* diff --git a/ntpd/refclock_dumbclock.c b/ntpd/refclock_dumbclock.c index 32e56f83d..f300ac9bc 100644 --- a/ntpd/refclock_dumbclock.c +++ b/ntpd/refclock_dumbclock.c @@ -121,7 +121,7 @@ dumbclock_start( printf ("starting Dumbclock with device %s\n",device); #endif fd = refclock_open(device, SPEED232, 0); - if (fd < 0) + if (!fd) return (0); /* diff --git a/ntpd/refclock_wwvb.c b/ntpd/refclock_wwvb.c index e327fb16f..e53104bb5 100644 --- a/ntpd/refclock_wwvb.c +++ b/ntpd/refclock_wwvb.c @@ -189,7 +189,7 @@ wwvb_start( * Open serial port. Use CLK line discipline, if available. */ snprintf(device, sizeof(device), DEVICE, unit); - if (-1 == (fd = refclock_open(device, SPEED232, LDISC_CLK))) + if (0 == (fd = refclock_open(device, SPEED232, LDISC_CLK))) return (0); /* diff --git a/ports/winnt/ntpd/win32_io.c b/ports/winnt/ntpd/win32_io.c index 3d91fa9dc..4274216c6 100644 --- a/ports/winnt/ntpd/win32_io.c +++ b/ports/winnt/ntpd/win32_io.c @@ -6,6 +6,7 @@ #include "ntp_machine.h" #include "ntp_stdlib.h" #include "ntp_syslog.h" +#include "ntp_assert.h" #include "ntp_debug.h" #include "ntp_fp.h" #include "ntp.h" @@ -158,7 +159,7 @@ int tty_open( * refclock_open - open serial port for reference clock * * This routine opens a serial port for I/O and sets default options. It - * returns the file descriptor or -1 indicating failure. + * returns the file descriptor or 0 indicating failure. */ int refclock_open( char * dev, /* device name pointer */ @@ -170,6 +171,7 @@ int refclock_open( HANDLE h; COMMTIMEOUTS timeouts; DCB dcb; + int fd; /* * open communication port handle @@ -180,13 +182,13 @@ int refclock_open( if (INVALID_HANDLE_VALUE == h) { msyslog(LOG_ERR, "Device %s CreateFile error: %m", windev); - return -1; + return 0; } /* Change the input/output buffers to be large. */ if (!SetupComm(h, 1024, 1024)) { msyslog(LOG_ERR, "Device %s SetupComm error: %m", windev); - return -1; + return 0; } dcb.DCBlength = sizeof(dcb); @@ -194,7 +196,7 @@ int refclock_open( if (!GetCommState(h, &dcb)) { msyslog(LOG_ERR, "Device %s GetCommState error: %m", windev); - return -1; + return 0; } switch (speed) { @@ -238,7 +240,7 @@ int refclock_open( default: msyslog(LOG_ERR, "Device %s unsupported baud rate " "code %u", windev, speed); - return -1; + return 0; } @@ -264,13 +266,13 @@ int refclock_open( if (!SetCommState(h, &dcb)) { msyslog(LOG_ERR, "Device %s SetCommState error: %m", windev); - return -1; + return 0; } /* watch out for CR (dcb.EvtChar) as well as the CD line */ if (!SetCommMask(h, EV_RXFLAG | EV_RLSD)) { msyslog(LOG_ERR, "Device %s SetCommMask error: %m", windev); - return -1; + return 0; } /* configure the handle to never block */ @@ -282,10 +284,14 @@ int refclock_open( if (!SetCommTimeouts(h, &timeouts)) { msyslog(LOG_ERR, "Device %s SetCommTimeouts error: %m", windev); - return -1; + return 0; } - return (int)_open_osfhandle((int)h, _O_TEXT); + fd = _open_osfhandle((int)h, _O_TEXT); + if (fd < 0) + return 0; + NTP_INSIST(fd != 0); + return fd; }