diff options
author | Jim Mussared <jim.mussared@gmail.com> | 2020-04-07 14:58:50 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2020-04-29 16:45:40 +1000 |
commit | 8119ec07652d6525beba876a29649dfe9e5fd621 (patch) | |
tree | 3682b2906e6e4c986dcf5ab98e7a89ef4e5a4642 /extmod/nimble/modbluetooth_nimble.c | |
parent | 0da47ecc93d3d12095e8d2df2ed80597f2ff4dd4 (diff) |
extmod/modbluetooth: Don't hold atomic section during mp_sched_schedule.
Because, for example, on unix the atomic section isn't re-entrant, and
mp_sched_schedule() will try to re-acquire the atomic section.
Diffstat (limited to 'extmod/nimble/modbluetooth_nimble.c')
-rw-r--r-- | extmod/nimble/modbluetooth_nimble.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/extmod/nimble/modbluetooth_nimble.c b/extmod/nimble/modbluetooth_nimble.c index 334a00b5e..9498e998b 100644 --- a/extmod/nimble/modbluetooth_nimble.c +++ b/extmod/nimble/modbluetooth_nimble.c @@ -613,17 +613,16 @@ int mp_bluetooth_gatts_set_buffer(uint16_t value_handle, size_t len, bool append #if MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE STATIC void gattc_on_data_available(uint16_t event, uint16_t conn_handle, uint16_t value_handle, const struct os_mbuf *om) { - MICROPY_PY_BLUETOOTH_ENTER size_t len = OS_MBUF_PKTLEN(om); - len = mp_bluetooth_gattc_on_data_available_start(event, conn_handle, value_handle, len); + mp_uint_t atomic_state; + len = mp_bluetooth_gattc_on_data_available_start(event, conn_handle, value_handle, len, &atomic_state); while (len > 0 && om != NULL) { size_t n = MIN(om->om_len, len); mp_bluetooth_gattc_on_data_available_chunk(OS_MBUF_DATA(om, const uint8_t *), n); len -= n; om = SLIST_NEXT(om, om_next); } - mp_bluetooth_gattc_on_data_available_end(); - MICROPY_PY_BLUETOOTH_EXIT + mp_bluetooth_gattc_on_data_available_end(atomic_state); } STATIC int gap_scan_cb(struct ble_gap_event *event, void *arg) { |