Skip to content

Commit

Permalink
Fixed corrupted messages when reopening a rosbag with a different file
Browse files Browse the repository at this point in the history
* Cleaned up more state in Bag::close() and ChunkedFile::close()
* It was not investigated how exactly the bug worked
  • Loading branch information
racko committed Oct 17, 2017
1 parent 4c91196 commit 1888f83
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tools/rosbag_storage/src/bag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,21 @@ void Bag::close() {
chunks_.clear();
connection_indexes_.clear();
curr_chunk_connection_indexes_.clear();

mode_ = bagmode::Write;
version_ = 0;
compression_ = compression::Uncompressed;
chunk_threshold_ = 768 * 1024; // 768KB chunks
bag_revision_ = 0;
file_size_ = 0;
file_header_pos_ = 0;
index_data_pos_ = 0;
connection_count_ = 0;
chunk_count_ = 0;
chunk_open_ = false;
curr_chunk_data_pos_ = 0;
current_buffer_ = 0;
decompressed_chunk_ = 0;
}

void Bag::closeWrite() {
Expand Down
2 changes: 2 additions & 0 deletions tools/rosbag_storage/src/chunked_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ void ChunkedFile::close() {
filename_.clear();

clearUnused();
offset_ = 0;
compressed_in_ = 0;
}

// Read/write modes
Expand Down

0 comments on commit 1888f83

Please sign in to comment.