LivoxProto1: Cancel async contin branch cbs in oracle fn

We were canceling the registered handler CBs in their branch
segments instead of in the unifying oracle fn.
This caused a bug where handlers were left behind in the
udpCmdDemuxer and thus a handler was invoked twice when a UDP
msg came in.
This commit is contained in:
2025-10-24 00:46:13 -04:00
parent d39dfb5334
commit 83c937ae8f
+8 -13
View File
@@ -625,16 +625,12 @@ private:
}
}
// This is called from the UDP command handler
void executeHandshakeReq1_2(
std::shared_ptr<ExecuteHandshakeReq> context,
const uint8_t* data, ssize_t bytesReceived,
const struct sockaddr_in& senderAddr
)
{
// Unregister the handler to decrement refcount
device.unregisterUdpCommandHandler(0x00, 0x01, context->deviceIP);
// Store the received data
context->bytesReceived = bytesReceived;
context->senderAddr = senderAddr;
@@ -661,13 +657,14 @@ private:
// Ensure we only execute once using atomic exchange
if (handlerExecuted.exchange(true) == true) { return; }
// Cancel timer if still running
timeoutTimer.cancel();
device.unregisterUdpCommandHandler(0x00, 0x01, deviceIP);
// Examine the flags and decide what happened
SocketState finalSocketState = socketState.load();
bool finalTimerFired = timerFired.load();
// Cancel timer if still running
timeoutTimer.cancel();
// Check for timeout only if there was no socket activity
if (finalTimerFired
&& finalSocketState == SocketState::SOCKET_STILL_WAITING)
@@ -1373,10 +1370,6 @@ protected:
const struct sockaddr_in& senderAddr
)
{
// Unregister the handler to decrement refcount
device.unregisterUdpCommandHandler(
0x00, 0x04, device.discoveredDevice.ipAddr);
// Store the received data
context->bytesReceived = bytesReceived;
context->senderAddr = senderAddr;
@@ -1405,11 +1398,13 @@ protected:
// Only execute once
if (context->handlerExecuted.exchange(true)) { return; }
context->timeoutTimer.cancel();
device.unregisterUdpCommandHandler(
0x00, 0x04, device.discoveredDevice.ipAddr);
SocketState finalSocketState = context->socketState.load();
bool finalTimerFired = context->timerFired.load();
context->timeoutTimer.cancel();
if (finalTimerFired &&
finalSocketState == SocketState::SOCKET_STILL_WAITING)
{