summaryrefslogtreecommitdiff
path: root/ntpshmwrite.c
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2015-03-10 14:11:37 -0700
committerGary E. Miller <gem@rellim.com>2015-03-10 14:11:37 -0700
commit990eda0328688517e9259113188a90533c751fbc (patch)
tree109eaa33014d94fb48effdd5a00c8e2a14cf2c3e /ntpshmwrite.c
parenta69e13c8b157dc66372daafff8f0e168ee3865a7 (diff)
downloadgpsd-990eda0328688517e9259113188a90533c751fbc.tar.gz
Only allow leap seconds in June and December.
Per Hal Murray and http://bugs.ntp.org/1090
Diffstat (limited to 'ntpshmwrite.c')
-rw-r--r--ntpshmwrite.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/ntpshmwrite.c b/ntpshmwrite.c
index f001d9ea..6370ee47 100644
--- a/ntpshmwrite.c
+++ b/ntpshmwrite.c
@@ -21,10 +21,24 @@
#include "ntpshm.h"
#include "compiler.h"
+#define LEAP_NOWARNING 0x0 /* normal, no leap second warning */
+
void ntp_write(volatile struct shmTime *shmseg,
struct timedelta_t *td, int precision, int leap_notify)
/* put a received fix time into shared memory for NTP */
{
+ struct tm tm;
+
+ /* insist that leap seconds only happen in june and december
+ * GPS emits leap pending for 3 months prior to insertion
+ * NTP expects leap pending for only 1 month prior to insertion
+ * Per http://bugs.ntp.org/1090 */
+ (void)gmtime_r( &(td->real.tv_sec), &tm);
+ if ( 5 != tm.tm_mon && 11 != tm.tm_mon ) {
+ /* Not june, not December, no way */
+ leap_notify = LEAP_NOWARNING;
+ }
+
/* we use the shmTime mode 1 protocol
*
* ntpd does this: