mirror of
https://github.com/espressif/openthread.git
synced 2026-08-30 05:49:54 +00:00
[mesh-forwarder] fix bug in evicting from address resolver queue (#4786)
The existing MeshForwarder::RemoveMessage() implementation is specific to evicting messages from mSendQueue. This commit generalizes the method by retrieving the queue from the message itself.
This commit is contained in:
+11
-11
@@ -723,6 +723,17 @@ public:
|
||||
return (!mBuffer.mHead.mInfo.mInPriorityQ) ? mBuffer.mHead.mInfo.mQueue.mMessage : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns a pointer to the priority message queue (if any) where this message is queued.
|
||||
*
|
||||
* @returns A pointer to the priority queue or NULL if not in any priority queue.
|
||||
*
|
||||
*/
|
||||
PriorityQueue *GetPriorityQueue(void) const
|
||||
{
|
||||
return (mBuffer.mHead.mInfo.mInPriorityQ) ? mBuffer.mHead.mInfo.mQueue.mPriority : NULL;
|
||||
}
|
||||
|
||||
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
|
||||
/**
|
||||
* This method indicates whether or not the message is also used for time sync purpose.
|
||||
@@ -810,17 +821,6 @@ private:
|
||||
*/
|
||||
void SetMessageQueue(MessageQueue *aMessageQueue);
|
||||
|
||||
/**
|
||||
* This method returns a pointer to the priority message queue (if any) where this message is queued.
|
||||
*
|
||||
* @returns A pointer to the priority queue or NULL if not in any priority queue.
|
||||
*
|
||||
*/
|
||||
PriorityQueue *GetPriorityQueue(void) const
|
||||
{
|
||||
return (mBuffer.mHead.mInfo.mInPriorityQ) ? mBuffer.mHead.mInfo.mQueue.mPriority : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method sets the message queue information for the message.
|
||||
*
|
||||
|
||||
@@ -139,19 +139,26 @@ exit:
|
||||
|
||||
void MeshForwarder::RemoveMessage(Message &aMessage)
|
||||
{
|
||||
#if OPENTHREAD_FTD
|
||||
for (ChildTable::Iterator iter(GetInstance(), Child::kInStateAnyExceptInvalid); !iter.IsDone(); iter++)
|
||||
PriorityQueue *queue = aMessage.GetPriorityQueue();
|
||||
|
||||
OT_ASSERT(queue != NULL);
|
||||
|
||||
if (queue == &mSendQueue)
|
||||
{
|
||||
IgnoreReturnValue(mIndirectSender.RemoveMessageFromSleepyChild(aMessage, *iter.GetChild()));
|
||||
}
|
||||
#if OPENTHREAD_FTD
|
||||
for (ChildTable::Iterator iter(GetInstance(), Child::kInStateAnyExceptInvalid); !iter.IsDone(); iter++)
|
||||
{
|
||||
IgnoreReturnValue(mIndirectSender.RemoveMessageFromSleepyChild(aMessage, *iter.GetChild()));
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mSendMessage == &aMessage)
|
||||
{
|
||||
mSendMessage = NULL;
|
||||
if (mSendMessage == &aMessage)
|
||||
{
|
||||
mSendMessage = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
mSendQueue.Dequeue(aMessage);
|
||||
queue->Dequeue(aMessage);
|
||||
LogMessage(kMessageEvict, aMessage, NULL, OT_ERROR_NO_BUFS);
|
||||
aMessage.Free();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user