diff --git a/core/federated/clock-sync.c b/core/federated/clock-sync.c index 2a6ce8e3d3..920758658d 100644 --- a/core/federated/clock-sync.c +++ b/core/federated/clock-sync.c @@ -531,9 +531,17 @@ void* listen_to_rti_UDP_thread(void* args) { // If clock synchronization is enabled, provide implementations. If not // just empty implementations that should be optimized away. #if defined(_LF_CLOCK_SYNC_ON) || defined(_LF_CLOCK_SYNC_INITIAL) -void clock_sync_add_offset(instant_t* t) { *t += (_lf_clock_sync_offset + _lf_clock_sync_constant_bias); } +void clock_sync_add_offset(instant_t* t) { + if (*t != FOREVER && *t != NEVER) { + *t += (_lf_clock_sync_offset + _lf_clock_sync_constant_bias); + } +} -void clock_sync_subtract_offset(instant_t* t) { *t -= (_lf_clock_sync_offset + _lf_clock_sync_constant_bias); } +void clock_sync_subtract_offset(instant_t* t) { + if (*t != FOREVER && *t != NEVER) { + *t -= (_lf_clock_sync_offset + _lf_clock_sync_constant_bias); + } +} void clock_sync_set_constant_bias(interval_t offset) { _lf_clock_sync_constant_bias = offset; } #else