Fix small bug in StreamBuffer

This commit is contained in:
2021-03-05 14:33:01 -05:00
parent c742bc5645
commit d29e471f1d
3 changed files with 7 additions and 6 deletions

View File

@@ -134,6 +134,7 @@ void LuaSnap::snapshot() {
void LuaSnap::rollback() { void LuaSnap::rollback() {
assert(snapshot_.write_count() != 0); assert(snapshot_.write_count() != 0);
deserialize(&snapshot_); deserialize(&snapshot_);
assert(snapshot_.at_eof());
snapshot_.clear(); snapshot_.clear();
} }

View File

@@ -54,6 +54,11 @@ void StreamBuffer::make_space_slow(int64_t bytes) {
int64_t existing_size = (buf_hi_ - buf_lo_); int64_t existing_size = (buf_hi_ - buf_lo_);
int64_t desired_size = 8192 + ((data_size + bytes) * 2); int64_t desired_size = 8192 + ((data_size + bytes) * 2);
// Update some simple things.
pre_read_count_ += (read_cursor_ - buf_lo_);
lua_reader_data_ = 0;
lua_reader_size_ = 0;
// Move the data to the beginning of the buffer, or to // Move the data to the beginning of the buffer, or to
// the beginning of a new buffer. // the beginning of a new buffer.
if (fixed_size_) { if (fixed_size_) {
@@ -70,13 +75,8 @@ void StreamBuffer::make_space_slow(int64_t bytes) {
} }
// Update the pointers to the data region. // Update the pointers to the data region.
pre_read_count_ += (read_cursor_ - buf_lo_);
read_cursor_ = buf_lo_; read_cursor_ = buf_lo_;
write_cursor_ = buf_lo_ + data_size; write_cursor_ = buf_lo_ + data_size;
// Flush the lua reader data, if any.
lua_reader_data_ = 0;
lua_reader_size_ = 0;
} }
char *StreamBuffer::get_overwrite(int64_t size, int64_t write_count_after) { char *StreamBuffer::get_overwrite(int64_t size, int64_t write_count_after) {