From c144edcf76ae6ae2eaa0e38b1a524bdb5faeae32 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 18 Jul 2024 16:01:45 +0200 Subject: [PATCH] XrdApps::JCache fix bug introduced when correcting main header offset --- src/XrdApps/XrdClJCachePlugin/cache/Journal.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/XrdApps/XrdClJCachePlugin/cache/Journal.cc b/src/XrdApps/XrdClJCachePlugin/cache/Journal.cc index a9430698573..466af684d56 100644 --- a/src/XrdApps/XrdClJCachePlugin/cache/Journal.cc +++ b/src/XrdApps/XrdClJCachePlugin/cache/Journal.cc @@ -147,12 +147,13 @@ int Journal::read_journal() { reset(); return cachesize; // sizeof (jheader_t) ; } + } else { + header_t *header = reinterpret_cast(buffer); + journal.insert(header->offset, header->offset + header->size, + totalBytesRead); + totalBytesRead += header->size; // size of the fragment + totalBytesRead += bytesRead; // size of the header } - header_t *header = reinterpret_cast(buffer); - journal.insert(header->offset, header->offset + header->size, - totalBytesRead); - totalBytesRead += header->size; // size of the fragment - totalBytesRead += bytesRead; // size of the header } while (bytesRead); return totalBytesRead; } @@ -384,7 +385,7 @@ int Journal::update_cache(std::vector &updates) { for (auto &u : updates) { rc = ::pwrite(fd, u.buff, u.size, - u.offset+sizeof(jheader_t)); // TODO is it safe to assume it will write it all + u.offset); // TODO is it safe to assume it will write it all if (rc <= 0) { return errno;