You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brpc.apache.org by ja...@apache.org on 2020/12/18 05:04:51 UTC
[incubator-brpc] branch master updated: add guarding logs for
recordio
This is an automated email from the ASF dual-hosted git repository.
jamesge pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git
The following commit(s) were added to refs/heads/master by this push:
new b34b776 add guarding logs for recordio
b34b776 is described below
commit b34b776c9ea56cd659105115b5e3eb93ae588714
Author: jamesge <jg...@gmail.com>
AuthorDate: Fri Dec 18 13:04:30 2020 +0800
add guarding logs for recordio
---
src/butil/iobuf.cpp | 6 +++---
src/butil/iobuf_inl.h | 6 ++----
src/butil/recordio.cc | 7 ++++++-
3 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/src/butil/iobuf.cpp b/src/butil/iobuf.cpp
index 56dd6b2..515f702 100644
--- a/src/butil/iobuf.cpp
+++ b/src/butil/iobuf.cpp
@@ -1794,13 +1794,13 @@ size_t IOBufCutter::cutn(butil::IOBuf* out, size_t n) {
_block };
out->_push_back_ref(r);
_data = (char*)_data + n;
- return n;
+ return n;
} else if (size != 0) {
const IOBuf::BlockRef r = { (uint32_t)((char*)_data - _block->data),
(uint32_t)size,
_block };
- out->_move_back_ref(r);
- _buf->_moveout_front_ref();
+ out->_push_back_ref(r);
+ _buf->_pop_front_ref();
_data = NULL;
_data_end = NULL;
_block = NULL;
diff --git a/src/butil/iobuf_inl.h b/src/butil/iobuf_inl.h
index 072023e..6a3d215 100644
--- a/src/butil/iobuf_inl.h
+++ b/src/butil/iobuf_inl.h
@@ -238,11 +238,9 @@ inline size_t IOBufCutter::pop_front(size_t n) {
_data = (char*)_data + n;
return saved_n;
}
- if (size != 0) {
- n -= size;
- }
+ n -= size;
if (!load_next_ref()) {
- return saved_n;
+ return saved_n - n;
}
} while (true);
}
diff --git a/src/butil/recordio.cc b/src/butil/recordio.cc
index 058271d..dc51cf9 100755
--- a/src/butil/recordio.cc
+++ b/src/butil/recordio.cc
@@ -287,7 +287,12 @@ int RecordReader::CutRecord(Record* rec) {
_ncut += meta_size;
consumed_bytes += 5 + name_size + meta_size;
}
- const size_t cut_bytes = _cutter.cutn(rec->MutablePayload(), data_size - consumed_bytes);
+ const size_t previous_payload_size = rec->Payload().size();
+ const size_t cut_bytes = _cutter.cutn(rec->MutablePayload(), data_size - consumed_bytes);
+ const size_t after_payload_size = rec->Payload().size();
+ if (cut_bytes != after_payload_size) {
+ LOG(ERROR) << "cut_bytes=" << cut_bytes << " does not match after_payload_size=" << after_payload_size << " previous_size=" << previous_payload_size << " data_size=" << data_size << " consumed_bytes=" << consumed_bytes;
+ }
if (cut_bytes != data_size - consumed_bytes) {
LOG(ERROR) << "cut_bytes=" << cut_bytes << " does not match input=" << data_size - consumed_bytes;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@brpc.apache.org
For additional commands, e-mail: dev-help@brpc.apache.org