From 1cb3d4ffe9c0463ddaefaa4450431b86680f179b Mon Sep 17 00:00:00 2001 From: peri4 Date: Thu, 14 Oct 2021 12:45:01 +0300 Subject: [PATCH] PIBinaryLog fix --- libs/main/io_devices/pibinarylog.cpp | 4 ++++ libs/main/io_devices/pibinarylog.h | 3 +++ 2 files changed, 7 insertions(+) diff --git a/libs/main/io_devices/pibinarylog.cpp b/libs/main/io_devices/pibinarylog.cpp index 14afc0ec..30fbc559 100644 --- a/libs/main/io_devices/pibinarylog.cpp +++ b/libs/main/io_devices/pibinarylog.cpp @@ -357,7 +357,9 @@ PIByteArray PIBinaryLog::readBinLog(int id, PISystemTime * time, int * readed_id if (readed_id) *readed_id = br.id; return br.data; } + logmutex.lock(); while (br.id != id && !isEnd()) br = readRecord(); + logmutex.unlock(); if (br.id == -1) { piCoutObj << "End of BinLog file"; fileEnd(); @@ -668,6 +670,7 @@ bool PIBinaryLog::createIndex() { void PIBinaryLog::seekTo(int rindex) { // piCoutObj << "seekTo"; logmutex.lock(); + pausemutex.lock(); if (rindex < index.size_s() && rindex >= 0) { file.seek(index[rindex].pos); moveIndex(index_pos.value(file.pos(), -1)); @@ -679,6 +682,7 @@ void PIBinaryLog::seekTo(int rindex) { } } // piCoutObj << "seekTo done"; + pausemutex.unlock(); logmutex.unlock(); } diff --git a/libs/main/io_devices/pibinarylog.h b/libs/main/io_devices/pibinarylog.h index 1ee25a27..4a5bcbea 100644 --- a/libs/main/io_devices/pibinarylog.h +++ b/libs/main/io_devices/pibinarylog.h @@ -201,6 +201,9 @@ public: //! Returns timestamp of last readed record PISystemTime lastReadedTimestamp() const {return lastrecord.timestamp;} + //! Returns timestamp of log start + PISystemTime logStartTimestamp() const {return startlogtime;} + //!Set custom file header, you can get it back when read this binlog void setHeader(const PIByteArray & header);