[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:
Jonathan Hui
2020-04-03 13:35:48 -07:00
committed by GitHub
parent f59641e484
commit 159dc8877c
2 changed files with 26 additions and 19 deletions
+11 -11
View File
@@ -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.
*
+15 -8
View File
@@ -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();
}