Skip to content

Commit 59a7467

Browse files
committed
file reader: fix reading of tfs with zero-length payload
1 parent 76e8652 commit 59a7467

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/common/SubTimeFrameFileReader.cxx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
#include <sys/mman.h>
2222
#endif
2323

24-
namespace o2
25-
{
26-
namespace DataDistribution
24+
namespace o2::DataDistribution
2725
{
2826

2927
using namespace o2::header;
@@ -85,10 +83,13 @@ std::size_t SubTimeFrameFileReader::getHeaderStackSize() // throws ios_base::fai
8583
auto lNumHeaders = 0;
8684
while (readNextHeader && (++lNumHeaders <= cMaxHeaders)) {
8785
// read BaseHeader only!
86+
const auto lBaseHdrPos = position();
8887
if(!read_advance(&lBaseHdr, sizeof(BaseHeader))) {
8988
return 0;
9089
}
9190

91+
// go back, and read the whole O2 header (Base+Derived)
92+
set_position(lBaseHdrPos);
9293
if (!ignore_nbytes(lBaseHdr.size())) {
9394
return 0;
9495
}
@@ -307,7 +308,7 @@ std::unique_ptr<SubTimeFrame> SubTimeFrameFileReader::read(SubTimeFrameFileBuild
307308
lStf->updateFirstOrbit(R.getOrbit());
308309
}
309310
} catch (...) {
310-
EDDLOG("Error getting RDHReader instace. Not setting firstOrbit for file data");
311+
EDDLOG("Error getting RDHReader instance. Not setting firstOrbit for file data");
311312
}
312313

313314
mStfData.emplace_back(std::move(lHdrStackMsg), std::move(lDataMsg));
@@ -326,5 +327,5 @@ std::unique_ptr<SubTimeFrame> SubTimeFrameFileReader::read(SubTimeFrameFileBuild
326327

327328
return lStf;
328329
}
329-
}
330+
330331
} /* o2::DataDistribution */

src/common/SubTimeFrameFileReader.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323
#include <fstream>
2424
#include <vector>
2525

26-
namespace o2
27-
{
28-
namespace DataDistribution
26+
namespace o2::DataDistribution
2927
{
3028

3129
class SubTimeFrameFileBuilder;
@@ -142,7 +140,7 @@ class SubTimeFrameFileReader : public ISubTimeFrameVisitor
142140
static std::uint64_t sStfId; // TODO: add id to files metadata
143141

144142
};
145-
}
143+
146144
} /* o2::DataDistribution */
147145

148146
#endif /* ALICEO2_SUBTIMEFRAME_FILE_READER_H_ */

0 commit comments

Comments
 (0)