Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions Framework/Core/src/DataProcessingDevice.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,19 @@ void DataProcessingDevice::Run()
auto* poolSizeEnv = getenv("DPL_THREADPOOL_SIZE");
bool dplEnableMultithreding = poolSizeEnv && std::atoi(poolSizeEnv) > 0;

while (state.transitionHandling != TransitionHandlingState::Expired) {
// A stream runs doRun on a pool thread and its completion is dispatched on
// this loop. Leaving while one is in flight lets FairMQ tear down the
// channels under a send which has not finished with them.
auto anyStreamRunning = [this]() {
return std::any_of(mStreams.begin(), mStreams.end(), [](TaskStreamInfo const& stream) { return stream.running; });
};

// The transition expires in the middle of the body, and what follows it still
// matters to a stream which is finishing: the asynchronous queue is drained
// down there, and that is how the oldest possible timeslice goes out. So keep
// going round rather than breaking out and waiting outside, which would run
// the completions but none of the work they queue.
while (state.transitionHandling != TransitionHandlingState::Expired || anyStreamRunning()) {
if (state.nextFairMQState.empty() == false) {
(void)this->ChangeState(state.nextFairMQState.back());
state.nextFairMQState.pop_back();
Expand Down Expand Up @@ -1352,7 +1364,7 @@ void DataProcessingDevice::Run()
using o2::monitoring::tags::Value;
// We have an empty stream, let's check if we have enough
// resources for it to run something
if (streamRef.index != -1) {
if (streamRef.index != -1 && state.transitionHandling != TransitionHandlingState::Expired) {
// Synchronous execution of the callbacks. This will be moved in the
// moved in the on_socket_polled once we have threading in place.
uv_work_t& handle = mHandles[streamRef.index];
Expand Down