git-svn-id: svn://db.shs.com.ru/pip@808 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2019-06-24 12:25:19 +00:00
parent 6da4f268d2
commit 8d712e54e5
2 changed files with 8 additions and 1 deletions

View File

@@ -384,7 +384,7 @@ PIByteArray & operator >>(PIByteArray & s, PIByteArray & v) {
int sz = 0; int sz = 0;
s >> sz; s >> sz;
if (sz > s.size_s()) { if (sz > s.size_s()) {
piCout << "[PIByteArray] Warning: operator >> wants too much data, discard!"; piCout << "[PIByteArray] Warning: operator >> wants too much data, discard!" << sz << s.size_s();
s.clear(); s.clear();
v.clear(); v.clear();
return s; return s;

View File

@@ -362,6 +362,7 @@ int PIBinaryLog::readDevice(void *read_to, int max_size) {
return -1; return -1;
} }
int sz = piMini(max_size, br.data.size()); int sz = piMini(max_size, br.data.size());
if (sz < br.data.size_s()) piCoutObj << "too small read buffer:" << max_size << ", data size:" << br.data.size();
memcpy(read_to, br.data.data(), sz); memcpy(read_to, br.data.data(), sz);
return sz; return sz;
} }
@@ -371,6 +372,7 @@ void PIBinaryLog::restart() {
bool th = isRunning(); bool th = isRunning();
if (th) stopThreadedRead(); if (th) stopThreadedRead();
if (!canRead()) return; if (!canRead()) return;
logmutex.unlock();
lastrecord.timestamp = PISystemTime(); lastrecord.timestamp = PISystemTime();
lastrecord.id = 0; lastrecord.id = 0;
is_thread_ok = true; is_thread_ok = true;
@@ -418,6 +420,7 @@ bool PIBinaryLog::checkFileHeader() {
PIBinaryLog::BinLogRecord PIBinaryLog::readRecord() { PIBinaryLog::BinLogRecord PIBinaryLog::readRecord() {
// piCoutObj << "readRecord";
logmutex.lock(); logmutex.lock();
PIByteArray ba; PIByteArray ba;
BinLogRecord br; BinLogRecord br;
@@ -430,6 +433,7 @@ PIBinaryLog::BinLogRecord PIBinaryLog::readRecord() {
} else { } else {
br.id = -1; br.id = -1;
logmutex.unlock(); logmutex.unlock();
// piCoutObj << "readRecord done";
return br; return br;
} }
if (br.id > 0 && br.size > 0) { if (br.id > 0 && br.size > 0) {
@@ -441,6 +445,7 @@ PIBinaryLog::BinLogRecord PIBinaryLog::readRecord() {
if (br.id == 0) fileError(); if (br.id == 0) fileError();
moveIndex(index_pos.value(file.pos(), -1)); moveIndex(index_pos.value(file.pos(), -1));
logmutex.unlock(); logmutex.unlock();
// piCoutObj << "readRecord done";
return br; return br;
} }
@@ -576,6 +581,7 @@ bool PIBinaryLog::createIndex() {
void PIBinaryLog::seekTo(int rindex) { void PIBinaryLog::seekTo(int rindex) {
// piCoutObj << "seekTo";
logmutex.lock(); logmutex.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);
@@ -583,6 +589,7 @@ void PIBinaryLog::seekTo(int rindex) {
play_time = index[rindex].timestamp.toMilliseconds(); play_time = index[rindex].timestamp.toMilliseconds();
lastrecord.timestamp = index[rindex].timestamp; lastrecord.timestamp = index[rindex].timestamp;
} }
// piCoutObj << "seekTo done";
logmutex.unlock(); logmutex.unlock();
} }