Bluetooth: Host: Detect deadlock in bt_att_req_alloc
`gatt_req_alloc` will wait until a `req` is free (or until timeout). `req`s are freed on the BT RX thread in calls into bt_att_recv. When `gatt_req_alloc` called on the BT RX thread itself when there are no free `req`s, it will block the BT RX thread and deadlock. The deadlock lasts until timeout. This change detects this condition and returns the failure early. Fixes https://github.com/zephyrproject-rtos/zephyr/issues/39624 where if `bt_gatt_write` is called from BT RX thread (as can happen if it is called from a bluetooth callback), the BT RX thread can be blocked and prevented from processing the request responses and unblocking itself. This was the cause of a soft 30s deadlock until gatt_req_alloc timeouts. Signed-off-by:Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Loading
Please sign in to comment