mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 12:35:28 +00:00
component/bt: free timer resources after using them
Bluedroid use a set of timer function pairs such as btu_start_timer/btu_stop_timer, btu_sys_start_timer/btu_sys_stop_timer for use, in a lack of timer release functions. Thus the timers may be exhausted after some event sequence such as repetition of connection/reconnection with different devices. The maximum timer number used in bluedroid is given by ALARM_CBS_NUM which is 30 for now. This bugfix borrowed some update from bluedroid in Andoroid 7.0, which add timer release functions which promote the recycle of timer resources.
This commit is contained in:
@@ -119,6 +119,7 @@ tCONN_CB *sdpu_allocate_ccb (void)
|
||||
/* Look through each connection control block for a free one */
|
||||
for (xx = 0, p_ccb = sdp_cb.ccb; xx < SDP_MAX_CONNECTIONS; xx++, p_ccb++) {
|
||||
if (p_ccb->con_state == SDP_STATE_IDLE) {
|
||||
btu_free_timer(&p_ccb->timer_entry);
|
||||
memset (p_ccb, 0, sizeof (tCONN_CB));
|
||||
|
||||
p_ccb->timer_entry.param = (UINT32) p_ccb;
|
||||
@@ -143,8 +144,8 @@ tCONN_CB *sdpu_allocate_ccb (void)
|
||||
*******************************************************************************/
|
||||
void sdpu_release_ccb (tCONN_CB *p_ccb)
|
||||
{
|
||||
/* Ensure timer is stopped */
|
||||
btu_stop_timer (&p_ccb->timer_entry);
|
||||
/* Ensure timer is stopped and released */
|
||||
btu_free_timer(&p_ccb->timer_entry);
|
||||
|
||||
/* Drop any response pointer we may be holding */
|
||||
p_ccb->con_state = SDP_STATE_IDLE;
|
||||
|
Reference in New Issue
Block a user