Skip to content

Commit 7bb8651

Browse files
committed
fix tof compressor-encoder rewind
1 parent ed85b4c commit 7bb8651

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

Detectors/TOF/compression/include/TOFCompression/Compressor.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,13 @@ class Compressor
151151
/** encoder private functions and data members **/
152152

153153
int encoderSpider(int itrm);
154-
inline void encoderRewind() { mEncoderPointer = reinterpret_cast<uint32_t*>(mEncoderBuffer); };
154+
inline void encoderRewind()
155+
{
156+
mEncoderPointer = reinterpret_cast<uint32_t*>(mEncoderBuffer);
157+
if (mEncoderPointerStart > mEncoderPointer) {
158+
mEncoderPointerStart = mEncoderPointer;
159+
}
160+
};
155161
inline int encoderNext()
156162
{
157163
if (mEncoderPointer + 1 >= mEncoderPointerMax) {

Detectors/TOF/compression/src/Compressor.cxx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,17 @@ bool Compressor<RDH, verbose, paranoid>::processHBF()
251251
mErrorCounter++;
252252
}
253253

254+
// before to move to RDH close check we are not already out of buffer (it is the last chance to call rewind and not to store RDH open)
255+
if (mEncoderPointer >= mEncoderPointerMax) {
256+
LOG(error) << "link = " << rdh->feeId << ": beyond the buffer size mEncoderPointer in RDH open = " << mEncoderPointer << " >= "
257+
<< "mEncoderPointerMax = " << mEncoderPointerMax;
258+
long byteOutOfBuffer = mEncoderPointer + rdh->headerSize - mEncoderPointerMax;
259+
LOG(error) << "byte out of buffer = " << byteOutOfBuffer;
260+
261+
encoderRewind();
262+
return true;
263+
}
264+
254265
/** copy RDH close to encoder buffer **/
255266
/** CAREFUL WITH THE PAGE COUNTER **/
256267
if (mEncoderPointer + rdh->headerSize >= mEncoderPointerMax) {

0 commit comments

Comments
 (0)