nimble/ll: Fix removing elements from the scheduler

This patch makes sure to start scheduler timer only for valid entry.
Also now function will return imidiatelly if scheduler list is empty.
This commit is contained in:
Łukasz Rymanowski
2019-02-22 21:02:16 +01:00
parent 9a9bac14a3
commit e7b0f49187
+8 -1
View File
@@ -1112,6 +1112,11 @@ ble_ll_sched_rmv_elem_type(uint8_t type, sched_remove_cb_func remove_cb)
OS_ENTER_CRITICAL(sr);
first = TAILQ_FIRST(&g_ble_ll_sched_q);
if (!first) {
OS_EXIT_CRITICAL(sr);
return;
}
TAILQ_FOREACH(entry, &g_ble_ll_sched_q, link) {
if (entry->sched_type == type) {
if (first == entry) {
@@ -1127,7 +1132,9 @@ ble_ll_sched_rmv_elem_type(uint8_t type, sched_remove_cb_func remove_cb)
if (!first) {
first = TAILQ_FIRST(&g_ble_ll_sched_q);
os_cputime_timer_start(&g_ble_ll_sched_timer, first->start_time);
if (first) {
os_cputime_timer_start(&g_ble_ll_sched_timer, first->start_time);
}
}
OS_EXIT_CRITICAL(sr);