You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2022/06/24 08:26:16 UTC

[mynewt-nimble] branch master updated: nimble/ll: Fix race between conn event and created

This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-nimble.git


The following commit(s) were added to refs/heads/master by this push:
     new 16f1e4d7 nimble/ll: Fix race between conn event and created
16f1e4d7 is described below

commit 16f1e4d7b289f3eeee87e877e49dff11f5e81bfc
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Tue Jun 21 16:32:54 2022 +0200

    nimble/ll: Fix race between conn event and created
    
    In rare cases it's possible that 1st connection event is fired before LL
    processed new connection, thus its state is set to idle. In such case we
    can just skip the event and LL will reschedule to next event, after the
    connection is fully created.
---
 nimble/controller/src/ble_ll_conn.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/nimble/controller/src/ble_ll_conn.c b/nimble/controller/src/ble_ll_conn.c
index 9dc897e5..0e2dffa0 100644
--- a/nimble/controller/src/ble_ll_conn.c
+++ b/nimble/controller/src/ble_ll_conn.c
@@ -1471,12 +1471,12 @@ ble_ll_conn_event_start_cb(struct ble_ll_sched_item *sch)
     connsm = (struct ble_ll_conn_sm *)sch->cb_arg;
     g_ble_ll_conn_cur_sm = connsm;
     BLE_LL_ASSERT(connsm);
+
+    /* In rare cases 1st connection event is fired before LL finished processing
+     * new connection. In such case just skip this connection event and LL will
+     * reschedule to next connection event.
+     */
     if (connsm->conn_state == BLE_LL_CONN_STATE_IDLE) {
-        /* That should not happen. If it does it means connection
-         * is already closed
-         */
-        STATS_INC(ble_ll_conn_stats, sched_start_in_idle);
-        BLE_LL_ASSERT(0);
         ble_ll_conn_current_sm_over(connsm);
         return BLE_LL_SCHED_STATE_DONE;
     }
@@ -1597,10 +1597,7 @@ ble_ll_conn_event_start_cb(struct ble_ll_sched_item *sch)
     }
 
     if (rc == BLE_LL_SCHED_STATE_DONE) {
-        ble_ll_event_add(&connsm->conn_ev_end);
-        ble_phy_disable();
-        ble_ll_state_set(BLE_LL_STATE_STANDBY);
-        g_ble_ll_conn_cur_sm = NULL;
+        ble_ll_conn_current_sm_over(connsm);
     }
 
     /* Set time that we last serviced the schedule */