From 9bb11e6e88dbfedb7a80114598ca00af604f4d8f Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 14 Jun 2022 16:07:39 -0500 Subject: [PATCH] Fix VxWorks time sync initialization bug --- modules/libcom/src/osi/os/vxWorks/osdTime.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/modules/libcom/src/osi/os/vxWorks/osdTime.cpp b/modules/libcom/src/osi/os/vxWorks/osdTime.cpp index 59bc5c87a..2fe679153 100644 --- a/modules/libcom/src/osi/os/vxWorks/osdTime.cpp +++ b/modules/libcom/src/osi/os/vxWorks/osdTime.cpp @@ -63,15 +63,18 @@ static int timeRegister(void) // Define EPICS_TS_FORCE_NTPTIME to force use of NTPTime provider bool useNTP = getenv("EPICS_TS_FORCE_NTPTIME") != NULL; - if (!useNTP && - (taskNameToId(sntp_sync_task) != ERROR || - taskNameToId(ntp_daemon) != ERROR)) { - // A VxWorks 6 SNTP/NTP sync task is running - struct timespec clockNow; + if (!useNTP) { + if (taskNameToId(sntp_sync_task) != ERROR || + taskNameToId(ntp_daemon) != ERROR) { + // A VxWorks 6 SNTP/NTP sync task is running + struct timespec clockNow; - useNTP = clock_gettime(CLOCK_REALTIME, &clockNow) != OK || - clockNow.tv_sec < BUILD_TIME; - // Assumes VxWorks and the host OS have the same epoch + useNTP = clock_gettime(CLOCK_REALTIME, &clockNow) != OK || + clockNow.tv_sec < BUILD_TIME; + // Assumes VxWorks and the host OS have the same epoch + } + else + useNTP = 1; } if (useNTP) {