]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 3066] NMEA clock ignores pps.
authorJuergen Perlinger <perlinger@ntp.org>
Sat, 23 Jul 2016 07:20:53 +0000 (09:20 +0200)
committerJuergen Perlinger <perlinger@ntp.org>
Sat, 23 Jul 2016 07:20:53 +0000 (09:20 +0200)
 (side kick: ignore msbuild 10 user settings file)

bk: 57931ad537lwf5OvSsTufk20O_OGrQ

ChangeLog
ports/winnt/ntpd/ntp_iocompletionport.c

index 0805467dc6b9b1ce7768a039f6a2d87af37546b9..21e250c06dc9d49487d6cbb6366340dcff998441 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+---
+* [Bug 3066] NMEA clock ignores pps. perlinger@ntp.org
+  - PPS-HACK works again.
+
 ---
 (4.2.8p8) 2016/06/02 Released by Harlan Stenn <stenn@ntp.org>
 
index 6512d75488fad971a1c784d2fc5ea4b7b654da4a..567bb1bd66d170a5a3653a189eb794a4627519fc 100644 (file)
@@ -107,6 +107,7 @@ static void free_io_completion_port_mem(void);
        HANDLE  WaitableIoEventHandle;
 static HANDLE  hndIOCPLPort;
 static HANDLE  hMainThread;
+static BOOL    DoPPShack;
 
 DWORD  ActiveWaitHandles;
 HANDLE WaitHandles[16];
@@ -214,11 +215,26 @@ void
 init_io_completion_port(void)
 {
        OSVERSIONINFO vi;
+       const char *    envp;
 
 #   ifdef DEBUG
        atexit(&free_io_completion_port_mem);
 #   endif
 
+       /* TODO: this should not be done via environment;
+        * It would be much better to have this as proper config option.
+        * (The same is true for the PPS API DLL list...)
+        */
+       if (NULL != (envp = getenv("PPSAPI_HACK")))
+               /* check for [Tt]{rue}, [Yy]{es}, or '1' as first char*/
+               DoPPShack = !!strchr("yYtT1", (u_char)*envp);
+       else if (NULL != (envp = getenv("PPSAPI_DLLS")))
+               /* any non-empty list disables PPS hack */
+               DoPPShack = !*envp;
+       else
+               /* otherwise use the PPS hack */
+               DoPPShack = TRUE;
+
        memset(&vi, 0, sizeof(vi));
        vi.dwOSVersionInfoSize = sizeof(vi);
 
@@ -626,7 +642,6 @@ QueueSerialWait(
 
        BOOL    rc;
 
-       memset(&lpo->aux, 0, sizeof(lpo->aux));
        lpo->onIoDone = OnSerialWaitComplete;
        lpo->recv_buf = buff;
        lpo->flRawMem = 0;
@@ -659,6 +674,7 @@ OnSerialWaitComplete(
 
        /* start next IO and leave if we hit an error */
        if (lpo->errCode != ERROR_SUCCESS) {
+               memset(&lpo->aux, 0, sizeof(lpo->aux));
                IoCtxStartLocked(lpo, QueueSerialWait, lpo->recv_buf);
                return;
        }
@@ -720,7 +736,7 @@ OnSerialWaitComplete(
                 *
                 * backward compat: 'usermode-pps-hack'
                 */
-               if (MS_RLSD_ON & modem_status) {
+               if ((MS_RLSD_ON & modem_status) && DoPPShack) {
                        lpo->aux.DCDSTime = lpo->aux.RecvTime;
                        lpo->aux.flTsDCDS = 1;
                        DPRINTF(2, ("upps-hack: fd %d DCD PPS Rise at %s\n",
@@ -837,6 +853,7 @@ OnSerialReadComplete(
 
 wait_again:
        /* make sure the read is issued again */
+       memset(&lpo->aux, 0, sizeof(lpo->aux));
        IoCtxStartLocked(lpo, QueueSerialWait, lpo->recv_buf);
 }
 
@@ -1299,6 +1316,7 @@ io_completion_port_add_clock_io(
                goto fail;
        }
        lpo->io.hnd = h;
+       memset(&lpo->aux, 0, sizeof(lpo->aux));
        return QueueSerialWait(lpo, get_free_recv_buffer_alloc());
 
 fail: