mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 13:25:30 +03:00
Merge pull request #6560 from AndersHoglund/fix_6348
Fix for issue #6348. Prevent dispatcher deadlock.
This commit is contained in:
commit
bfee80b3df
2 changed files with 10 additions and 1 deletions
|
@ -51,6 +51,7 @@ void dispatchProcess(uint32_t currentTime)
|
||||||
// unlink entry first, so handler can replan self
|
// unlink entry first, so handler can replan self
|
||||||
dispatchEntry_t *current = *p;
|
dispatchEntry_t *current = *p;
|
||||||
*p = (*p)->next;
|
*p = (*p)->next;
|
||||||
|
current->inQue = false;
|
||||||
(*current->dispatch)(current);
|
(*current->dispatch)(current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,10 +59,17 @@ void dispatchProcess(uint32_t currentTime)
|
||||||
void dispatchAdd(dispatchEntry_t *entry, int delayUs)
|
void dispatchAdd(dispatchEntry_t *entry, int delayUs)
|
||||||
{
|
{
|
||||||
uint32_t delayedUntil = micros() + delayUs;
|
uint32_t delayedUntil = micros() + delayUs;
|
||||||
entry->delayedUntil = delayedUntil;
|
|
||||||
dispatchEntry_t **p = &head;
|
dispatchEntry_t **p = &head;
|
||||||
|
|
||||||
|
if (entry->inQue) {
|
||||||
|
return; // Allready in Queue, abort
|
||||||
|
}
|
||||||
|
|
||||||
while (*p && cmp32((*p)->delayedUntil, delayedUntil) < 0)
|
while (*p && cmp32((*p)->delayedUntil, delayedUntil) < 0)
|
||||||
p = &(*p)->next;
|
p = &(*p)->next;
|
||||||
|
|
||||||
entry->next = *p;
|
entry->next = *p;
|
||||||
|
entry->delayedUntil = delayedUntil;
|
||||||
|
entry->inQue = true;
|
||||||
*p = entry;
|
*p = entry;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ typedef struct dispatchEntry_s {
|
||||||
dispatchFunc *dispatch;
|
dispatchFunc *dispatch;
|
||||||
uint32_t delayedUntil;
|
uint32_t delayedUntil;
|
||||||
struct dispatchEntry_s *next;
|
struct dispatchEntry_s *next;
|
||||||
|
bool inQue;
|
||||||
} dispatchEntry_t;
|
} dispatchEntry_t;
|
||||||
|
|
||||||
bool dispatchIsEnabled(void);
|
bool dispatchIsEnabled(void);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue