mynewt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From w...@apache.org
Subject [2/2] incubator-mynewt-core git commit: Fix scheduling bugs
Date Mon, 16 May 2016 20:31:19 GMT
Fix scheduling bugs

There were two scheduling bugs that were uncovered during recent
testing. The first was that we should have removed the schedule
element prior to calling the connection start callback. The
second is that a currently scheduled connection could get moved
when a new connection is added. Both of these bugs could cause
connections to become disconnected if more than one connection
is ongoing.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/4d5aa14f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/4d5aa14f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/4d5aa14f

Branch: refs/heads/develop
Commit: 4d5aa14f6dcca4be04581367b786c3daa873ea05
Parents: c4d1c7a
Author: William San Filippo <wills@runtime.io>
Authored: Mon May 16 13:07:12 2016 -0700
Committer: William San Filippo <wills@runtime.io>
Committed: Mon May 16 13:07:12 2016 -0700

----------------------------------------------------------------------
 net/nimble/controller/src/ble_ll_sched.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4d5aa14f/net/nimble/controller/src/ble_ll_sched.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_sched.c b/net/nimble/controller/src/ble_ll_sched.c
index 82f4189..5b79217 100644
--- a/net/nimble/controller/src/ble_ll_sched.c
+++ b/net/nimble/controller/src/ble_ll_sched.c
@@ -340,9 +340,6 @@ ble_ll_sched_master_new(struct ble_ll_conn_sm *connsm, uint32_t adv_rxend,
             connsm->tx_win_off = (earliest_start - initial_start) /
                 cputime_usecs_to_ticks(BLE_LL_CONN_ITVL_USECS);
         }
-
-        /* Restart with head of list */
-        sch = TAILQ_FIRST(&g_ble_ll_sched_q);
     }
 
     if (!rc) {
@@ -353,6 +350,9 @@ ble_ll_sched_master_new(struct ble_ll_conn_sm *connsm, uint32_t adv_rxend,
         connsm->ce_end_time = earliest_end;
     }
 
+    /* Get head of list to restart timer */
+    sch = TAILQ_FIRST(&g_ble_ll_sched_q);
+
     OS_EXIT_CRITICAL(sr);
 
     cputime_timer_start(&g_ble_ll_sched_timer, sch->start_time);
@@ -669,10 +669,10 @@ ble_ll_sched_run(void *arg)
     while ((sch = TAILQ_FIRST(&g_ble_ll_sched_q)) != NULL) {
         /* Make sure we have passed the start time of the first event */
         if ((int32_t)(cputime_get32() - sch->start_time) >= 0) {
-            /* Execute the schedule item and remove it when done */
-            ble_ll_sched_execute_item(sch);
+            /* Remove schedule item and execute the callback */
             TAILQ_REMOVE(&g_ble_ll_sched_q, sch, link);
             sch->enqueued = 0;
+            ble_ll_sched_execute_item(sch);
         } else {
             cputime_timer_start(&g_ble_ll_sched_timer, sch->start_time);
             break;


Mime
View raw message