Lots of work on debugging diff xmit

This commit is contained in:
2021-11-21 13:35:39 -05:00
parent 0881e33c6f
commit b19825aaca
23 changed files with 338 additions and 99 deletions

View File

@@ -182,7 +182,14 @@ void IdPlayerPool::diff(const IdPlayerPool &auth, StreamBuffer *sb) const {
assert(valid());
assert(auth.valid());
// Special case: there's nothing to fix.
if (exactly_equal(auth)) {
sb->write_uint8(255);
return;
}
// Write the fifo capacity and nranges
assert(auth.fifo_capacity_ != 255);
sb->write_uint8(auth.fifo_capacity_);
sb->write_uint8(auth.ranges_.size());
@@ -206,9 +213,14 @@ void IdPlayerPool::diff(const IdPlayerPool &auth, StreamBuffer *sb) const {
}
}
void IdPlayerPool::patch(StreamBuffer *sb) {
void IdPlayerPool::patch(StreamBuffer *sb, DebugCollector *dbc) {
// read the header byte
int fifo_cap = sb->read_uint8();
// If the fifo_cap is 255, it means there's nothing to fix.
if (fifo_cap == 255) {
return;
}
DebugLine(dbc) << "IdPlayerPool modified";
fifo_capacity_ = fifo_cap;
int nranges = sb->read_uint8();
std::deque<int64_t> old = std::move(ranges_);
@@ -381,7 +393,7 @@ LuaDefine(unittests_idalloc, "c") {
// Check case: no differences.
sb.clear();
ppds.diff(pp, &sb);
ppds.patch(&sb);
ppds.patch(&sb, nullptr);
LuaAssert(L, ppds.exactly_equal(pp));
// Add some values to master pool
@@ -391,7 +403,7 @@ LuaDefine(unittests_idalloc, "c") {
// transmit and compare.
sb.clear();
ppds.diff(pp, &sb);
ppds.patch(&sb);
ppds.patch(&sb, nullptr);
LuaAssert(L, ppds.exactly_equal(pp));
// Pop a value from master pool
@@ -401,7 +413,7 @@ LuaDefine(unittests_idalloc, "c") {
// transmit and compare.
sb.clear();
ppds.diff(pp, &sb);
ppds.patch(&sb);
ppds.patch(&sb, nullptr);
LuaAssert(L, ppds.exactly_equal(pp));
return 0;