mirror of https://git.kore.io/kore.git
Fix concurrency problem in coroutines.
If a coroutine is woken up from another coroutine running from an http request we can end up in a case where the call path looks like: 0 kore_worker_entry 1 epoll wait <- bound to pending timers 2 http_process <- first coro sleep 3 kore_python_coro_run <- wakes up request 4 http_process <- wakes up another coroutine 5 return to kore_worker_entry In the case where 4 wakes up another coroutine but 1 is bound to a timer and no io activity occurs the coroutine isn't run until the timer fires. Fix this issue by always checking for pending coroutines even if the netwait isn't INFINITE.
This commit is contained in:
parent
fd2cda5a43
commit
9227347b90
|
@ -474,13 +474,14 @@ kore_worker_entry(struct kore_worker *kw)
|
||||||
#if !defined(KORE_NO_HTTP)
|
#if !defined(KORE_NO_HTTP)
|
||||||
if (http_request_count > 0)
|
if (http_request_count > 0)
|
||||||
netwait = 100;
|
netwait = 100;
|
||||||
#endif
|
|
||||||
#if defined(KORE_USE_PYTHON)
|
|
||||||
if (kore_python_coro_pending())
|
|
||||||
netwait = 10;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(KORE_USE_PYTHON)
|
||||||
|
if (kore_python_coro_pending())
|
||||||
|
netwait = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
kore_platform_event_wait(netwait);
|
kore_platform_event_wait(netwait);
|
||||||
now = kore_time_ms();
|
now = kore_time_ms();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue