mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-26 03:23:35 +08:00
Fixed linked list traversing in Dispatcher
This commit is contained in:
@@ -62,7 +62,7 @@ void LoopbackFrameListenerRegistry::invokeListeners(RxFrame& frame)
|
|||||||
while (p)
|
while (p)
|
||||||
{
|
{
|
||||||
LoopbackFrameListenerBase* const next = p->getNextListNode();
|
LoopbackFrameListenerBase* const next = p->getNextListNode();
|
||||||
p->handleLoopbackFrame(frame);
|
p->handleLoopbackFrame(frame); // p may be modified
|
||||||
p = next;
|
p = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,8 +113,9 @@ void Dispatcher::ListenerRegistry::cleanup(MonotonicTime ts)
|
|||||||
TransferListenerBase* p = list_.get();
|
TransferListenerBase* p = list_.get();
|
||||||
while (p)
|
while (p)
|
||||||
{
|
{
|
||||||
p->cleanup(ts);
|
TransferListenerBase* const next = p->getNextListNode();
|
||||||
p = p->getNextListNode();
|
p->cleanup(ts); // p may be modified
|
||||||
|
p = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,15 +124,16 @@ void Dispatcher::ListenerRegistry::handleFrame(const RxFrame& frame)
|
|||||||
TransferListenerBase* p = list_.get();
|
TransferListenerBase* p = list_.get();
|
||||||
while (p)
|
while (p)
|
||||||
{
|
{
|
||||||
|
TransferListenerBase* const next = p->getNextListNode();
|
||||||
if (p->getDataTypeDescriptor().getID() == frame.getDataTypeID())
|
if (p->getDataTypeDescriptor().getID() == frame.getDataTypeID())
|
||||||
{
|
{
|
||||||
p->handleFrame(frame);
|
p->handleFrame(frame); // p may be modified
|
||||||
}
|
}
|
||||||
else if (p->getDataTypeDescriptor().getID() < frame.getDataTypeID()) // Listeners are ordered by data type id!
|
else if (p->getDataTypeDescriptor().getID() < frame.getDataTypeID()) // Listeners are ordered by data type id!
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
p = p->getNextListNode();
|
p = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user