You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/11/03 13:21:23 UTC

[GitHub] rymanluk closed pull request #229: nimble/ll: Remove outstanding aux_data on scan stop

rymanluk closed pull request #229: nimble/ll: Remove outstanding aux_data on scan stop
URL: https://github.com/apache/mynewt-nimble/pull/229
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/nimble/controller/include/controller/ble_ll_sched.h b/nimble/controller/include/controller/ble_ll_sched.h
index 15f75007..6c7d8a07 100644
--- a/nimble/controller/include/controller/ble_ll_sched.h
+++ b/nimble/controller/include/controller/ble_ll_sched.h
@@ -82,7 +82,7 @@ extern uint8_t g_ble_ll_sched_offset_ticks;
 /* Callback function */
 struct ble_ll_sched_item;
 typedef int (*sched_cb_func)(struct ble_ll_sched_item *sch);
-
+typedef void (*sched_remove_cb_func)(struct ble_ll_sched_item *sch);
 /*
  * Strict connection scheduling (for the master) is different than how
  * connections are normally scheduled. With strict connection scheduling we
@@ -143,6 +143,8 @@ int ble_ll_sched_init(void);
 /* Remove item(s) from schedule */
 void ble_ll_sched_rmv_elem(struct ble_ll_sched_item *sch);
 
+void ble_ll_sched_rmv_elem_type(uint8_t type, sched_remove_cb_func remove_cb);
+
 /* Schedule a new master connection */
 struct ble_ll_conn_sm;
 int ble_ll_sched_master_new(struct ble_ll_conn_sm *connsm,
diff --git a/nimble/controller/src/ble_ll_scan.c b/nimble/controller/src/ble_ll_scan.c
index 16fea1ee..8b484913 100644
--- a/nimble/controller/src/ble_ll_scan.c
+++ b/nimble/controller/src/ble_ll_scan.c
@@ -1109,7 +1109,13 @@ ble_ll_scan_window_chk(struct ble_ll_scan_sm *scansm, uint32_t cputime)
 
     return 0;
 }
-
+#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV)
+static void
+ble_ll_scan_sched_remove(struct ble_ll_sched_item *sch)
+{
+    ble_ll_scan_aux_data_free(sch->cb_arg);
+}
+#endif
 /**
  * Stop the scanning state machine
  */
@@ -1132,6 +1138,8 @@ ble_ll_scan_sm_stop(int chk_disable)
     OS_ENTER_CRITICAL(sr);
     ble_ll_scan_clean_cur_aux_data();
     OS_EXIT_CRITICAL(sr);
+
+    ble_ll_sched_rmv_elem_type(BLE_LL_SCHED_TYPE_AUX_SCAN, ble_ll_scan_sched_remove);
 #endif
 
     /* Count # of times stopped */
diff --git a/nimble/controller/src/ble_ll_sched.c b/nimble/controller/src/ble_ll_sched.c
index bb2a7f1d..3e341ff1 100644
--- a/nimble/controller/src/ble_ll_sched.c
+++ b/nimble/controller/src/ble_ll_sched.c
@@ -1098,6 +1098,37 @@ ble_ll_sched_rmv_elem(struct ble_ll_sched_item *sch)
     OS_EXIT_CRITICAL(sr);
 }
 
+void
+ble_ll_sched_rmv_elem_type(uint8_t type, sched_remove_cb_func remove_cb)
+{
+    os_sr_t sr;
+    struct ble_ll_sched_item *entry;
+    struct ble_ll_sched_item *first;
+
+    OS_ENTER_CRITICAL(sr);
+    first = TAILQ_FIRST(&g_ble_ll_sched_q);
+
+    TAILQ_FOREACH(entry, &g_ble_ll_sched_q, link) {
+        if (entry->sched_type == type) {
+            if (first == entry) {
+                os_cputime_timer_stop(&g_ble_ll_sched_timer);
+                first = NULL;
+            }
+
+            TAILQ_REMOVE(&g_ble_ll_sched_q, entry, link);
+            remove_cb(entry);
+            entry->enqueued = 0;
+        }
+    }
+
+    if (!first) {
+        first = TAILQ_FIRST(&g_ble_ll_sched_q);
+        os_cputime_timer_start(&g_ble_ll_sched_timer, first->start_time);
+    }
+
+    OS_EXIT_CRITICAL(sr);
+}
+
 /**
  * Executes a schedule item by calling the schedule callback function.
  *


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services