Comment 3 for bug 697516

Revision history for this message
Jeff Hill (johill-lanl) wrote :

committed this fix

=== modified file 'src/libCom/osi/os/WIN32/osdTime.cpp'
--- src/libCom/osi/os/WIN32/osdTime.cpp 2011-11-10 21:03:01 +0000
+++ src/libCom/osi/os/WIN32/osdTime.cpp 2011-11-10 21:47:18 +0000
@@ -303,8 +303,8 @@
     }
     else {
         errlogPrintf (
- "win32 osdTime.cpp detected questionable "
- "system date prior to EPICS epoch\n" );
+ "win32 osdTime.cpp init detected questionable "
+ "system date prior to EPICS epoch, epics time will not advance\n" );
         this->epicsTimeLast = 0;
     }

@@ -483,9 +483,32 @@
             / this->perfCounterFreq;
     this->lastPerfCounter = curPerfCounter.QuadPart;

- LONGLONG epicsTimeFromCurrentFileTime =
- ( curFileTime.QuadPart - epicsEpochInFileTime ) *
- ET_TICKS_PER_FT_TICK;
+ LONGLONG epicsTimeFromCurrentFileTime;
+
+ {
+ static bool firstMessageWasSent = false;
+ if ( curFileTime.QuadPart >= epicsEpochInFileTime ) {
+ epicsTimeFromCurrentFileTime =
+ ( curFileTime.QuadPart - epicsEpochInFileTime ) *
+ ET_TICKS_PER_FT_TICK;
+ firstMessageWasSent = false;
+ }
+ else {
+ /*
+ * if the system time jumps to before the EPICS epoch
+ * then latch to the EPICS epoch printing only one
+ * warning message the first time that the issue is
+ * detected
+ */
+ if ( ! firstMessageWasSent ) {
+ errlogPrintf (
+ "win32 osdTime.cpp time PLL update detected questionable "
+ "system date prior to EPICS epoch, epics time will not advance\n" );
+ firstMessageWasSent = true;
+ }
+ epicsTimeFromCurrentFileTime = 0;
+ }
+ }

     delta = epicsTimeFromCurrentFileTime - this->epicsTimeLast;
     if ( delta > EPICS_TIME_TICKS_PER_SEC || delta < -EPICS_TIME_TICKS_PER_SEC ) {