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

Commit 6dfd9194 authored by Antoine SOULIER's avatar Antoine SOULIER
Browse files

HCI: Failing to open the snoop-log is not fatal

Bug: 350816694
Test: m -j;
Change-Id: I6daedaa7772f5ddbf86cee780d933716ee262e82
parent 37de3cb8
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));
    }