From 8d712e54e5e139d52564111143a2d607be818b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=8B=D1=87=D0=BA=D0=BE=D0=B2=20=D0=90=D0=BD=D0=B4?= =?UTF-8?q?=D1=80=D0=B5=D0=B9?= Date: Mon, 24 Jun 2019 12:25:19 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/pip@808 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5 --- src_main/core/pibytearray.cpp | 2 +- src_main/io_devices/pibinarylog.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src_main/core/pibytearray.cpp b/src_main/core/pibytearray.cpp index 3408d3ff..b68a42b5 100755 --- a/src_main/core/pibytearray.cpp +++ b/src_main/core/pibytearray.cpp @@ -384,7 +384,7 @@ PIByteArray & operator >>(PIByteArray & s, PIByteArray & v) { int sz = 0; s >> sz; 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(); v.clear(); return s; diff --git a/src_main/io_devices/pibinarylog.cpp b/src_main/io_devices/pibinarylog.cpp index 6f62a164..e7de37e9 100644 --- a/src_main/io_devices/pibinarylog.cpp +++ b/src_main/io_devices/pibinarylog.cpp @@ -362,6 +362,7 @@ int PIBinaryLog::readDevice(void *read_to, int max_size) { return -1; } 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); return sz; } @@ -371,6 +372,7 @@ void PIBinaryLog::restart() { bool th = isRunning(); if (th) stopThreadedRead(); if (!canRead()) return; + logmutex.unlock(); lastrecord.timestamp = PISystemTime(); lastrecord.id = 0; is_thread_ok = true; @@ -418,6 +420,7 @@ bool PIBinaryLog::checkFileHeader() { PIBinaryLog::BinLogRecord PIBinaryLog::readRecord() { +// piCoutObj << "readRecord"; logmutex.lock(); PIByteArray ba; BinLogRecord br; @@ -430,6 +433,7 @@ PIBinaryLog::BinLogRecord PIBinaryLog::readRecord() { } else { br.id = -1; logmutex.unlock(); +// piCoutObj << "readRecord done"; return br; } if (br.id > 0 && br.size > 0) { @@ -441,6 +445,7 @@ PIBinaryLog::BinLogRecord PIBinaryLog::readRecord() { if (br.id == 0) fileError(); moveIndex(index_pos.value(file.pos(), -1)); logmutex.unlock(); +// piCoutObj << "readRecord done"; return br; } @@ -576,6 +581,7 @@ bool PIBinaryLog::createIndex() { void PIBinaryLog::seekTo(int rindex) { +// piCoutObj << "seekTo"; logmutex.lock(); if (rindex < index.size_s() && rindex >= 0) { file.seek(index[rindex].pos); @@ -583,6 +589,7 @@ void PIBinaryLog::seekTo(int rindex) { play_time = index[rindex].timestamp.toMilliseconds(); lastrecord.timestamp = index[rindex].timestamp; } +// piCoutObj << "seekTo done"; logmutex.unlock(); }