From b252fe15ffd4b5c2941085254f70ef1dc66437fb Mon Sep 17 00:00:00 2001 From: Arseny Smirnov Date: Fri, 13 Jul 2018 14:42:03 +0300 Subject: [PATCH] Binlog: reader bugfix GitOrigin-RevId: 38271e40782e52d0ab20e74d98d10fc4045ac0c0 --- tddb/td/db/binlog/Binlog.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tddb/td/db/binlog/Binlog.cpp b/tddb/td/db/binlog/Binlog.cpp index 63f687c92..28aab4d90 100644 --- a/tddb/td/db/binlog/Binlog.cpp +++ b/tddb/td/db/binlog/Binlog.cpp @@ -100,6 +100,10 @@ class BinlogReader { expected_size_ = expected_size; } + ChainBufferReader *input() { + return input_; + } + int64 offset() const { return offset_; } @@ -462,7 +466,6 @@ Status Binlog::load_binlog(const Callback &callback, const Callback &debug_callb update_read_encryption(); - bool ready_flag = false; fd_.update_flags(Fd::Flag::Read); info_.wrong_password = false; while (true) { @@ -492,18 +495,16 @@ Status Binlog::load_binlog(const Callback &callback, const Callback &debug_callb return Status::OK(); } } - ready_flag = false; } else { // TODO(now): fix bug - if (ready_flag) { - break; - } TRY_STATUS(fd_.flush_read(max(need_size, static_cast(4096)))); buffer_reader_.sync_with_writer(); if (byte_flow_flag_) { byte_flow_source_.wakeup(); } - ready_flag = true; + if (reader.input()->size() < need_size) { + break; + } } }