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() {
assert(snapshot_.write_count() != 0);
deserialize(&snapshot_);
assert(snapshot_.at_eof());
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 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
// the beginning of a new buffer.
if (fixed_size_) {
@@ -70,13 +75,8 @@ void StreamBuffer::make_space_slow(int64_t bytes) {
}
// Update the pointers to the data region.
pre_read_count_ += (read_cursor_ - buf_lo_);
read_cursor_ = buf_lo_;
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) {

View File

@@ -344,7 +344,7 @@ public:
// Rewind the read cursor to a previous position.
void unread_to(int64_t read_count);
// Use the stream buffer as a lua_Writer.
static int lua_writer(lua_State *L, const void* p, size_t sz, void* ud);
void *lua_writer_ud();