From: Juergen Perlinger Date: Sat, 23 Jul 2016 07:20:53 +0000 (+0200) Subject: [Bug 3066] NMEA clock ignores pps. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3760483800fd983658b537ad943fac359a84d996;p=thirdparty%2Fntp.git [Bug 3066] NMEA clock ignores pps. (side kick: ignore msbuild 10 user settings file) bk: 57931ad537lwf5OvSsTufk20O_OGrQ --- diff --git a/ChangeLog b/ChangeLog index 0805467dc..21e250c06 100644 --- 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 diff --git a/ports/winnt/ntpd/ntp_iocompletionport.c b/ports/winnt/ntpd/ntp_iocompletionport.c index 6512d7548..567bb1bd6 100644 --- a/ports/winnt/ntpd/ntp_iocompletionport.c +++ b/ports/winnt/ntpd/ntp_iocompletionport.c @@ -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: