forked from Archive/PX4-Autopilot
Mixer: Make reset operation more robust
This change makes the operation more robust as it flags the whole group invalid in the first step. This should not be confused with being thread-safe - to be thread-safe, all accesses to _first and the following linked list need to be guarded by a mutex. This should be done outside of the mixer in the driver though, as the method depends on the board architecture.
This commit is contained in:
parent
66b9ee2d24
commit
5b70522541
|
@ -88,11 +88,15 @@ void
|
|||
MixerGroup::reset()
|
||||
{
|
||||
Mixer *mixer;
|
||||
Mixer *next = _first;
|
||||
|
||||
/* flag mixer as invalid */
|
||||
_first = nullptr;
|
||||
|
||||
/* discard sub-mixers */
|
||||
while (_first != nullptr) {
|
||||
mixer = _first;
|
||||
_first = mixer->_next;
|
||||
while (next != nullptr) {
|
||||
mixer = next;
|
||||
next = mixer->_next;
|
||||
delete mixer;
|
||||
mixer = nullptr;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue