From 68811617fcdf1d815dfea6462eedef7073ce4fbb Mon Sep 17 00:00:00 2001
From: meschi <emilio.meschi@cern.ch>
Date: Thu, 3 Nov 2022 20:53:45 +0100
Subject: [PATCH] revert handling of last slice in processor destructor (as it
 creates problems elsewhere)

---
 src/InputFilter.cc |  3 ++-
 src/processor.cc   | 12 +++++++-----
 src/processor.h    |  2 --
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/InputFilter.cc b/src/InputFilter.cc
index 81c2ba47..f63c9f09 100644
--- a/src/InputFilter.cc
+++ b/src/InputFilter.cc
@@ -163,6 +163,7 @@ void *InputFilter::operator()(void *) {
 
   // Adjust the end of this buffer
   thisSlice->set_end(thisSlice->end() + bytesRead);
-
+  //  LOG(TRACE) << " Input filter returns slice at 0x" << std::hex <<
+  //  (uint64_t)thisSlice;
   return thisSlice;
 }
diff --git a/src/processor.cc b/src/processor.cc
index 845342b4..29de5f95 100644
--- a/src/processor.cc
+++ b/src/processor.cc
@@ -14,8 +14,7 @@ StreamProcessor::StreamProcessor(size_t max_size_, bool doZS_,
                                  ProcessorType processorType_,
                                  uint32_t nOrbitsPerDMAPacket_,
                                  uint32_t prescaleFactor_, ctrl &control_)
-    : tbb::filter(parallel), next_slice_(Slice::getAllocated()),
-      max_size(max_size_), nbPackets(0), doZS(doZS_),
+    : tbb::filter(parallel), max_size(max_size_), nbPackets(0), doZS(doZS_),
       processorType(processorType_), nOrbitsPerDMAPacket(nOrbitsPerDMAPacket_),
       prescaleFactor(prescaleFactor_), control(control_) {
   LOG(TRACE) << "Created transform filter at " << static_cast<void *>(this);
@@ -38,7 +37,9 @@ void bit_check(std::vector<unsigned int> *bx_vect, uint32_t word,
   return;
 }
 
-StreamProcessor::~StreamProcessor() { Slice::giveAllocated(next_slice_); }
+StreamProcessor::~StreamProcessor() {
+  //  Slice::giveAllocated(next_slice_);
+}
 
 // checks that the packet size is an integer multiple of the BX block size,
 // minus the header/trailers
@@ -467,9 +468,10 @@ void StreamProcessor::process(Slice &input, Slice &out) {
 }
 void *StreamProcessor::operator()(void *item) {
   Slice &input = *static_cast<Slice *>(item);
-  Slice &out = *next_slice_;
+  //	LOG(TRACE) << "Processor gets slice at " << &input;
+  Slice &out = *Slice::getAllocated();
   process(input, out);
   Slice::giveAllocated(&input);
-  next_slice_ = Slice::getAllocated();
+
   return &out;
 }
diff --git a/src/processor.h b/src/processor.h
index 12bbdd54..c85f34d0 100644
--- a/src/processor.h
+++ b/src/processor.h
@@ -42,8 +42,6 @@ private:
   fillOrbitMetadata FillOrbitCalo(std::vector<unsigned int> &bx_vect,
                                   char *rd_ptr, char *wr_ptr);
   uint32_t FillBril(char *rd_ptr, char *wr_ptr, char *end_ptr);
-  Slice *next_slice_;
-  ;
   size_t max_size;
   uint64_t nbPackets;
   bool doZS;
-- 
GitLab