Fix for issue 6348. Prevent dispatcher deadlock.

This commit is contained in:
Anders Hoglund 2018-08-15 10:39:26 +02:00
parent 9d01a5681e
commit 924817c253
2 changed files with 10 additions and 1 deletions

View File

@ -51,6 +51,7 @@ void dispatchProcess(uint32_t currentTime)
// unlink entry first, so handler can replan self
dispatchEntry_t *current = *p;
*p = (*p)->next;
current->inQue = false;
(*current->dispatch)(current);
}
}
@ -58,10 +59,17 @@ void dispatchProcess(uint32_t currentTime)
void dispatchAdd(dispatchEntry_t *entry, int delayUs)
{
uint32_t delayedUntil = micros() + delayUs;
entry->delayedUntil = delayedUntil;
dispatchEntry_t **p = &head;
if (entry->inQue) {
return; // Allready in Queue, abort
}
while (*p && cmp32((*p)->delayedUntil, delayedUntil) < 0)
p = &(*p)->next;
entry->next = *p;
entry->delayedUntil = delayedUntil;
entry->inQue = true;
*p = entry;
}

View File

@ -27,6 +27,7 @@ typedef struct dispatchEntry_s {
dispatchFunc *dispatch;
uint32_t delayedUntil;
struct dispatchEntry_s *next;
bool inQue;
} dispatchEntry_t;
bool dispatchIsEnabled(void);