PIBinaryLog fix

This commit is contained in:
peri4
2021-10-14 12:45:01 +03:00
parent 9293706634
commit 1cb3d4ffe9
2 changed files with 7 additions and 0 deletions

View File

@@ -357,7 +357,9 @@ PIByteArray PIBinaryLog::readBinLog(int id, PISystemTime * time, int * readed_id
if (readed_id) *readed_id = br.id; if (readed_id) *readed_id = br.id;
return br.data; return br.data;
} }
logmutex.lock();
while (br.id != id && !isEnd()) br = readRecord(); while (br.id != id && !isEnd()) br = readRecord();
logmutex.unlock();
if (br.id == -1) { if (br.id == -1) {
piCoutObj << "End of BinLog file"; piCoutObj << "End of BinLog file";
fileEnd(); fileEnd();
@@ -668,6 +670,7 @@ bool PIBinaryLog::createIndex() {
void PIBinaryLog::seekTo(int rindex) { void PIBinaryLog::seekTo(int rindex) {
// piCoutObj << "seekTo"; // piCoutObj << "seekTo";
logmutex.lock(); logmutex.lock();
pausemutex.lock();
if (rindex < index.size_s() && rindex >= 0) { if (rindex < index.size_s() && rindex >= 0) {
file.seek(index[rindex].pos); file.seek(index[rindex].pos);
moveIndex(index_pos.value(file.pos(), -1)); moveIndex(index_pos.value(file.pos(), -1));
@@ -679,6 +682,7 @@ void PIBinaryLog::seekTo(int rindex) {
} }
} }
// piCoutObj << "seekTo done"; // piCoutObj << "seekTo done";
pausemutex.unlock();
logmutex.unlock(); logmutex.unlock();
} }

View File

@@ -201,6 +201,9 @@ public:
//! Returns timestamp of last readed record //! Returns timestamp of last readed record
PISystemTime lastReadedTimestamp() const {return lastrecord.timestamp;} 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 //!Set custom file header, you can get it back when read this binlog
void setHeader(const PIByteArray & header); void setHeader(const PIByteArray & header);