Skip to content

Commit 8d37ba8

Browse files
committed
DPL: update what "now" means before setting the timer
Due to the fact we do not invoke uv_run unless there is some idle time between some data and the other, the concept of "now" in libuv is not updated. This means that when we setup a timer, libuv thinks it's still the past. However when we run uv_run e.g. because data is not arriving anymore, the time suddenly switches to the correct one, triggering the callback immediately, because the 20 seconds from the moment in the past have already passed. This explains why end of stream is missed (FairMQ simply switched already to the READY state) or why some race condition which should not be so frequent (like the one for START-STOP-START), is so frequent.
1 parent 6e19e74 commit 8d37ba8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Framework/Core/src/DataProcessingDevice.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,7 @@ void DataProcessingDevice::initPollers()
542542
auto* timer = (uv_timer_t*)malloc(sizeof(uv_timer_t));
543543
uv_timer_init(mState.loop, timer);
544544
timer->data = &mState;
545+
uv_update_time(mState.loop);
545546
uv_timer_start(timer, on_idle_timer, 2000, 2000);
546547
mState.activeTimers.push_back(timer);
547548
}
@@ -779,6 +780,7 @@ void DataProcessingDevice::Run()
779780
auto timeout = mDeviceContext.exitTransitionTimeout;
780781
if (timeout != 0 && mState.streaming != StreamingState::Idle) {
781782
mState.transitionHandling = TransitionHandlingState::Requested;
783+
uv_update_time(mState.loop);
782784
uv_timer_start(mDeviceContext.gracePeriodTimer, on_transition_requested_expired, timeout * 1000, 0);
783785
if (mProcessingPolicies.termination == TerminationPolicy::QUIT) {
784786
LOGP(info, "New state requested. Waiting for {} seconds before quitting.", timeout);

0 commit comments

Comments
 (0)