Cleanup: do not use global isSkipPacket from rx handler
rx handler returns true when it needs to skip reporting.
Bug: 375952239
Test: stress test
Change-Id: I3102e3b6ea4612d9b64645cd3a2850e90bf18314
Merged-In: I3102e3b6ea4612d9b64645cd3a2850e90bf18314
diff --git a/halimpl/hal/phNxpUciHal.cc b/halimpl/hal/phNxpUciHal.cc
index 18ca177..1ff9472 100644
--- a/halimpl/hal/phNxpUciHal.cc
+++ b/halimpl/hal/phNxpUciHal.cc
@@ -104,11 +104,13 @@
rx_handlers.remove(handler);
}
-static void phNxpUciHal_rx_handler_check(size_t packet_len, const uint8_t *packet)
+// Returns true when this packet is handled by one of the handler.
+static bool phNxpUciHal_rx_handler_check(size_t packet_len, const uint8_t *packet)
{
const uint8_t mt = ((packet[0]) & UCI_MT_MASK) >> UCI_MT_SHIFT;
const uint8_t gid = packet[0] & UCI_GID_MASK;
const uint8_t oid = packet[1] & UCI_OID_MASK;
+ bool skip_packet = false;
std::lock_guard<std::mutex> guard(rx_handlers_lock);
@@ -116,13 +118,15 @@
if (mt == handler->mt && gid == handler->gid && oid == handler->oid) {
handler->callback(packet_len, packet);
if (handler->skip_reporting) {
- nxpucihal_ctrl.isSkipPacket = 1;
+ skip_packet = true;
}
}
}
rx_handlers.remove_if([mt, gid, oid](auto& handler) {
return mt == handler->mt && gid == handler->gid && oid == handler->oid && handler->run_once;
});
+
+ return skip_packet;
}
static void phNxpUciHal_rx_handler_destroy(void)
@@ -449,7 +453,9 @@
nxpucihal_ctrl.isSkipPacket = 0;
- phNxpUciHal_rx_handler_check(length, buffer);
+ if (phNxpUciHal_rx_handler_check(length, buffer)) {
+ nxpucihal_ctrl.isSkipPacket = true;
+ }
// mapping device caps according to Fira 2.0
if (mt == UCI_MT_RSP && gid == UCI_GID_CORE && oid == UCI_MSG_CORE_GET_CAPS_INFO) {