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:
@@ -625,16 +625,12 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
// This is called from the UDP command handler
|
||||
void executeHandshakeReq1_2(
|
||||
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)
|
||||
@@ -1371,12 +1368,8 @@ protected:
|
||||
std::shared_ptr<EnDisablePcloudDataReq<CallbackType>> context,
|
||||
const uint8_t* data, ssize_t bytesReceived,
|
||||
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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user