Skip to content

Commit

Permalink
DPL: correctly handle data-processing-timeouts in sources
Browse files Browse the repository at this point in the history
  • Loading branch information
ktf committed Feb 17, 2025
1 parent eb14b21 commit db2de1a
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions Framework/Core/src/DataProcessingDevice.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,19 @@ void on_data_processing_expired(uv_timer_t* handle)
{
auto* ref = (ServiceRegistryRef*)handle->data;
auto& state = ref->get<DeviceState>();
auto& spec = ref->get<DeviceSpec const>();
state.loopReason |= DeviceState::TIMER_EXPIRED;

// Check if this is a source device
O2_SIGNPOST_ID_FROM_POINTER(cid, device, handle);

// Source devices should never end up in this callback, since the exitTransitionTimeout should
// be reset to the dataProcessingTimeout and the timers cohalesced.
assert(hasOnlyGenerated(ref->get<DeviceSpec const>()) == false);
O2_SIGNPOST_EVENT_EMIT_INFO(calibration, cid, "callback", "Grace period for data processing expired. Only calibrations from this point onwards.");
state.allowedProcessing = DeviceState::CalibrationOnly;
if (hasOnlyGenerated(spec)) {
O2_SIGNPOST_EVENT_EMIT_INFO(calibration, cid, "callback", "Grace period for data processing expired. Switching to EndOfStreaming.");
switchState(*ref, StreamingState::EndOfStreaming);
} else {
O2_SIGNPOST_EVENT_EMIT_INFO(calibration, cid, "callback", "Grace period for data processing expired. Only calibrations from this point onwards.");
state.allowedProcessing = DeviceState::CalibrationOnly;
}
}

void on_communication_requested(uv_async_t* s)
Expand Down Expand Up @@ -1379,13 +1382,6 @@ void DataProcessingDevice::Run()
switchState(ref, StreamingState::EndOfStreaming);
}

// If this is a source device, exitTransitionTimeout and dataProcessingTimeout are effectively
// the same (because source devices are not allowed to produce any calibration).
// should be the same.
if (hasOnlyGenerated(spec) && deviceContext.dataProcessingTimeout > 0) {
deviceContext.exitTransitionTimeout = deviceContext.dataProcessingTimeout;
}

// We do not do anything in particular if the data processing timeout would go past the exitTransitionTimeout
if (deviceContext.dataProcessingTimeout > 0 && deviceContext.dataProcessingTimeout < deviceContext.exitTransitionTimeout) {
uv_update_time(state.loop);
Expand Down

0 comments on commit db2de1a

Please sign in to comment.