@@ -402,6 +402,12 @@ void DataRelayer::pruneCache(TimesliceSlot slot, OnDropCallback onDrop)
402402 pruneCache (slot);
403403}
404404
405+ bool isCalibrationData (std::unique_ptr<fair::mq::Message>& first)
406+ {
407+ auto * dh = o2::header::get<DataHeader*>(first->GetData ());
408+ return dh->flagsDerivedHeader & DataProcessingHeader::KEEP_AT_EOS_FLAG;
409+ }
410+
405411DataRelayer::RelayChoice
406412 DataRelayer::relay (void const * rawHeader,
407413 std::unique_ptr<fair::mq::Message>* messages,
@@ -456,7 +462,7 @@ DataRelayer::RelayChoice
456462 &nPayloads,
457463 &cache = mCache ,
458464 &services = mContext ,
459- numInputTypes = mDistinctRoutesIndex .size ()](TimesliceId timeslice, int input, TimesliceSlot slot, InputInfo const & info) {
465+ numInputTypes = mDistinctRoutesIndex .size ()](TimesliceId timeslice, int input, TimesliceSlot slot, InputInfo const & info) -> size_t {
460466 O2_SIGNPOST_ID_GENERATE (aid, data_relayer);
461467 O2_SIGNPOST_EVENT_EMIT (data_relayer, aid, " saveInSlot" , " saving %{public}s@%zu in slot %zu from %{public}s" ,
462468 fmt::format (" {:x}" , *o2::header::get<DataHeader*>(messages[0 ]->GetData ())).c_str (),
@@ -468,11 +474,20 @@ DataRelayer::RelayChoice
468474 // TODO: make sure that multiple parts can only be added within the same call of
469475 // DataRelayer::relay
470476 assert (nPayloads > 0 );
477+ size_t saved = 0 ;
471478 for (size_t mi = 0 ; mi < nMessages; ++mi) {
472479 assert (mi + nPayloads < nMessages);
480+ // We are in calibration mode and the data does not have the calibration bit set.
481+ // We do not store it.
482+ if (services.get <DeviceState>().allowedProcessing == DeviceState::ProcessingType::CalibrationOnly && !isCalibrationData (messages[mi])) {
483+ mi += nPayloads;
484+ continue ;
485+ }
473486 target.add ([&messages, &mi](size_t i) -> fair::mq::MessagePtr& { return messages[mi + i]; }, nPayloads + 1 );
474487 mi += nPayloads;
488+ saved += nPayloads;
475489 }
490+ return saved;
476491 };
477492
478493 auto updateStatistics = [ref = mContext ](TimesliceIndex::ActionTaken action) {
@@ -551,7 +566,10 @@ DataRelayer::RelayChoice
551566 this ->pruneCache (slot, onDrop);
552567 mPruneOps .erase (std::remove_if (mPruneOps .begin (), mPruneOps .end (), [slot](const auto & x) { return x.slot == slot; }), mPruneOps .end ());
553568 }
554- saveInSlot (timeslice, input, slot, info);
569+ size_t saved = saveInSlot (timeslice, input, slot, info);
570+ if (saved == 0 ) {
571+ return RelayChoice{.type = RelayChoice::Type::Dropped, .timeslice = timeslice};
572+ }
555573 index.publishSlot (slot);
556574 index.markAsDirty (slot, true );
557575 stats.updateStats ({static_cast <short >(ProcessingStatsId::RELAYED_MESSAGES), DataProcessingStats::Op::Add, (int )1 });
@@ -633,7 +651,10 @@ DataRelayer::RelayChoice
633651 // cache still holds the old data, so we prune it.
634652 this ->pruneCache (slot, onDrop);
635653 mPruneOps .erase (std::remove_if (mPruneOps .begin (), mPruneOps .end (), [slot](const auto & x) { return x.slot == slot; }), mPruneOps .end ());
636- saveInSlot (timeslice, input, slot, info);
654+ size_t saved = saveInSlot (timeslice, input, slot, info);
655+ if (saved == 0 ) {
656+ return RelayChoice{.type = RelayChoice::Type::Dropped, .timeslice = timeslice};
657+ }
637658 index.publishSlot (slot);
638659 index.markAsDirty (slot, true );
639660 return RelayChoice{.type = RelayChoice::Type::WillRelay};
0 commit comments