Skip to content
Snippets Groups Projects
Commit 6070a0e4 authored by Giovanna Lazzari Miotto's avatar Giovanna Lazzari Miotto :mushroom:
Browse files

DAX on, hardcoded GMT file size

parent e6dde519
No related branches found
No related tags found
No related merge requests found
......@@ -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) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment