AOS was not writing timestamp data header
AOS wasn't writing out the header to the timestamp data log part. Which
means the log part is corrupted and can't be read. Let's fix the bug
that's causing that, and put some checks in so if a log doesn't have a
header if throws a more helpful error than a segfault.
This was only happening when trying to relog a logfile with a
pre-existing config.
Change-Id: I373821f4cfbead90daddd820d3c61693e8886eda
Signed-off-by: Austin Schuh <austin.schuh@bluerivertech.com>
diff --git a/aos/events/logging/log_namer.cc b/aos/events/logging/log_namer.cc
index a97ba5e..a880f35 100644
--- a/aos/events/logging/log_namer.cc
+++ b/aos/events/logging/log_namer.cc
@@ -388,10 +388,17 @@
LOG(FATAL) << "Can't log forwarded timestamps in a singe log file.";
return nullptr;
}
-
MultiNodeLogNamer::MultiNodeLogNamer(std::string_view base_name,
EventLoop *event_loop)
- : LogNamer(event_loop), base_name_(base_name), old_base_name_() {}
+ : MultiNodeLogNamer(base_name, event_loop->configuration(), event_loop,
+ event_loop->node()) {}
+
+MultiNodeLogNamer::MultiNodeLogNamer(std::string_view base_name,
+ const Configuration *configuration,
+ EventLoop *event_loop, const Node *node)
+ : LogNamer(configuration, event_loop, node),
+ base_name_(base_name),
+ old_base_name_() {}
MultiNodeLogNamer::~MultiNodeLogNamer() {
if (!ran_out_of_space_) {
@@ -432,7 +439,8 @@
writer->QueueSizedFlatbuffer(header->Release());
if (!writer->ran_out_of_space()) {
- all_filenames_.emplace_back(filename);
+ all_filenames_.emplace_back(
+ absl::StrCat(config_sha256, ".bfbs", extension_));
}
CloseWriter(&writer);
}
@@ -499,7 +507,7 @@
nodes_.emplace_back(node);
}
- NewDataWriter data_writer(this, node,
+ NewDataWriter data_writer(this, configuration::GetNode(configuration_, node),
[this, channel](NewDataWriter *data_writer) {
OpenForwardedTimestampWriter(channel,
data_writer);