diff --git a/src/FileDmaInputFilter.cc b/src/FileDmaInputFilter.cc index f020376e01710694499949ca1b27577bfc580552..0e87762f35a6b4149d7867ba190f43d4f2290836 100644 --- a/src/FileDmaInputFilter.cc +++ b/src/FileDmaInputFilter.cc @@ -2,13 +2,10 @@ #include <fcntl.h> #include <sys/mman.h> -#include <sys/stat.h> -#include <sys/types.h> #include <unistd.h> #include <cassert> #include <cerrno> -#include <cstdint> #include <cstring> #include <sstream> #include <system_error> @@ -83,6 +80,8 @@ static inline ssize_t read_dma_packet_from_file(FILE *inputFile, char *buffer, s if (rc != 32) { if (feof(inputFile) && rc == 0 && bytesRead == 0) { // We have reached the perfect end of the file, let's start again + std::cout << "Reached EOF, rewinding file! It's been " << std::to_string(nbReads) + << " read calls." << std::endl; fseek(inputFile, 0, SEEK_SET); continue; } @@ -157,6 +156,12 @@ inline ssize_t FileDmaInputFilter::readPacket(char **buffer, ssize_t bufferSize) // bufferSize must be multiple of page size std::cout << "Current mmap offset: " << std::to_string(mmap_offset_) << " out of " << std::to_string(DAX_LENGTH) << std::endl; + + if (mmap_offset_ >= 9050784) { + std::cout << "Mmap offset is at EOF, we start over" << std::endl; + mmap_offset_ = 0; + } + bytesRead = read_dma_packet_buffer(mmap_buffer_ + mmap_offset_, *buffer, bufferSize); mmap_offset_ += bytesRead; std::cout << "Bytes read: " << std::to_string(bytesRead) << std::endl; @@ -185,6 +190,7 @@ inline ssize_t FileDmaInputFilter::readPacket(char **buffer, ssize_t bufferSize) #else bytesRead = read_dma_packet_from_file(inputFile, *buffer, bufferSize, nbReads()); + std::cout << "Bytes read: " << std::to_string(bytesRead) << std::endl; // If large packet returned, skip and read again while (bytesRead > (ssize_t)bufferSize) {