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.
@@ -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,8 +1132,10 @@ 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);
+ if (first) {
os_cputime_timer_start(&g_ble_ll_sched_timer, first->start_time);
}
+ }
OS_EXIT_CRITICAL(sr);
}
