Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d10e4e6d authored by Antoine Soulier's avatar Antoine Soulier Committed by Gerrit Code Review
Browse files

Merge "HCI: Failing to open the snoop-log is not fatal" into main

parents c1ee4950 6dfd9194
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -548,17 +548,21 @@ void SnoopLogger::OpenNextSnoopLogFile() {
  file_creation_time = fake_timerfd_get_clock();
#endif
  if (!btsnoop_ostream_.good()) {
    log::fatal("Unable to open snoop log at \"{}\", error: \"{}\"", snoop_log_path_,
    log::error("Unable to open snoop log at \"{}\", error: \"{}\"", snoop_log_path_,
               strerror(errno));
    return;
  }
  umask(prevmask);
  if (!btsnoop_ostream_.write(reinterpret_cast<const char*>(&SnoopLoggerCommon::kBtSnoopFileHeader),
                              sizeof(SnoopLoggerCommon::FileHeaderType))) {
    log::fatal("Unable to write file header to \"{}\", error: \"{}\"", snoop_log_path_,
    log::error("Unable to write file header to \"{}\", error: \"{}\"", snoop_log_path_,
               strerror(errno));
    btsnoop_ostream_.close();
    return;
  }
  if (!btsnoop_ostream_.flush()) {
    log::error("Failed to flush, error: \"{}\"", strerror(errno));
    return;
  }
}

@@ -1191,6 +1195,9 @@ void SnoopLogger::Capture(const HciPacket& immutable_packet, Direction direction
    if (packet_counter_ > max_packets_per_file_) {
      OpenNextSnoopLogFile();
    }
    if (!btsnoop_ostream_.is_open() || !btsnoop_ostream_.good()) {
      return;
    }
    if (!btsnoop_ostream_.write(reinterpret_cast<const char*>(&header), sizeof(PacketHeaderType))) {
      log::error("Failed to write packet header for btsnoop, error: \"{}\"", strerror(errno));
    }