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

Commit e67113ce authored by Yun-Hao Chung's avatar Yun-Hao Chung
Browse files

Floss: Log time spent in closing socket

We've recently observed that closing an HCI socket sometimes takes
longer than 1 second. This patch allows us to record the time it takes
to close the socket to further collect the high delay case by feedback
report analyzers.

Bug: 365936141
Tag: #floss
Test: mmm packages/modules/Bluetooth
Test: manual adaper enable/disable, verify the syslog
Flag: EXEMPT, Floss-only changes
Change-Id: I905358ad96b2eba244bf6ee26fa9059704396f31
parent 535a6b8f
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@

#include <chrono>  // NOLINT
#include <csignal>
#include <cstdint>
#include <mutex>  // NOLINT
#include <queue>
#include <utility>
@@ -369,7 +370,11 @@ protected:
      std::lock_guard<std::mutex> incoming_packet_callback_lock(incoming_packet_callback_mutex_);
      incoming_packet_callback_ = nullptr;
    }
    auto start = std::chrono::high_resolution_clock::now();
    ::close(sock_fd_);
    auto end = std::chrono::high_resolution_clock::now();
    int64_t duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
    log::info("Spent {} milliseconds on closing socket", duration);
    sock_fd_ = INVALID_FD;
    log::info("HAL is closed");
  }