crypto: fix lockup when stack is shutdown while waiting for result of HCI Command, e.g. LE Read Local P256 Public Key

This commit is contained in:
Matthias Ringwald 2019-02-05 17:23:51 +01:00
parent beceedde07
commit 0c23bea1f5
2 changed files with 13 additions and 0 deletions

View File

@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased]
### Fixed
- Crypto: fix lockup when stack is shutdown while waiting for result of HCI Command, e.g. LE Read Local P256 Public Key
## Changes December 2018
### Changed
- L2CAP: provide channel mode (basic/ertm) and fcs option in L2CAP_EVENT_CHANNEL_OPENED
- RFCOMM: support L2CAP ERTM. Callbacks passed to rfcomm_enable_l2cap_ertm() are used to manage ERTM buffers

View File

@ -944,6 +944,14 @@ static void btstack_crypto_event_handler(uint8_t packet_type, uint16_t cid, uint
if (packet_type != HCI_EVENT_PACKET) return;
switch (hci_event_packet_get_type(packet)){
case BTSTACK_EVENT_STATE:
log_info("BTSTACK_EVENT_STATE");
if (btstack_event_state_get_state(packet) != HCI_STATE_HALTING) break;
if (!btstack_crypto_wait_for_hci_result) break;
// request stack to defer shutdown a bit
hci_halting_defer();
break;
case HCI_EVENT_COMMAND_COMPLETE:
if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_le_encrypt)){
if (hci_get_state() != HCI_STATE_WORKING) return;