mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-09 20:41:14 +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:
@@ -169,6 +169,7 @@ tRFC_MCB *rfc_alloc_multiplexer_channel (BD_ADDR bd_addr, BOOLEAN is_initiator)
|
||||
if (rfc_cb.port.rfc_mcb[j].state == RFC_MX_STATE_IDLE) {
|
||||
/* New multiplexer control block */
|
||||
fixed_queue_free(p_mcb->cmd_q, NULL);
|
||||
rfc_timer_free(p_mcb);
|
||||
memset (p_mcb, 0, sizeof (tRFC_MCB));
|
||||
memcpy (p_mcb->bd_addr, bd_addr, BD_ADDR_LEN);
|
||||
RFCOMM_TRACE_DEBUG("rfc_alloc_multiplexer_channel:is_initiator:%d, create new p_mcb:%p, index:%d",
|
||||
@@ -201,7 +202,7 @@ void osi_free_fun(void *p){
|
||||
void rfc_release_multiplexer_channel (tRFC_MCB *p_mcb)
|
||||
{
|
||||
|
||||
rfc_timer_stop (p_mcb);
|
||||
rfc_timer_free (p_mcb);
|
||||
|
||||
fixed_queue_free(p_mcb->cmd_q, osi_free_fun);
|
||||
|
||||
@@ -228,7 +229,6 @@ void rfc_timer_start (tRFC_MCB *p_mcb, UINT16 timeout)
|
||||
btu_start_timer (p_tle, BTU_TTYPE_RFCOMM_MFC, timeout);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function rfc_timer_stop
|
||||
@@ -243,6 +243,20 @@ void rfc_timer_stop (tRFC_MCB *p_mcb)
|
||||
btu_stop_timer (&p_mcb->tle);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function rfc_timer_free
|
||||
**
|
||||
** Description Stop and free RFC Timer
|
||||
**
|
||||
*******************************************************************************/
|
||||
void rfc_timer_free (tRFC_MCB *p_mcb)
|
||||
{
|
||||
RFCOMM_TRACE_EVENT ("rfc_timer_free");
|
||||
|
||||
btu_free_timer (&p_mcb->tle);
|
||||
memset(&p_mcb->tle, 0, sizeof(TIMER_LIST_ENT));
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -262,7 +276,6 @@ void rfc_port_timer_start (tPORT *p_port, UINT16 timeout)
|
||||
btu_start_timer (p_tle, BTU_TTYPE_RFCOMM_PORT, timeout);
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function rfc_port_timer_stop
|
||||
@@ -274,9 +287,23 @@ void rfc_port_timer_stop (tPORT *p_port)
|
||||
{
|
||||
RFCOMM_TRACE_EVENT ("rfc_port_timer_stop");
|
||||
|
||||
btu_free_timer (&p_port->rfc.tle);
|
||||
btu_stop_timer (&p_port->rfc.tle);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function rfc_port_timer_free
|
||||
**
|
||||
** Description Stop and free RFC Timer
|
||||
**
|
||||
*******************************************************************************/
|
||||
void rfc_port_timer_free (tPORT *p_port)
|
||||
{
|
||||
RFCOMM_TRACE_EVENT ("rfc_port_timer_stop");
|
||||
|
||||
btu_free_timer (&p_port->rfc.tle);
|
||||
memset(&p_port->rfc.tle, 0, sizeof(TIMER_LIST_ENT));
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -480,4 +507,4 @@ void rfc_check_send_cmd(tRFC_MCB *p_mcb, BT_HDR *p_buf)
|
||||
}
|
||||
|
||||
|
||||
#endif ///(defined RFCOMM_INCLUDED && RFCOMM_INCLUDED == TRUE)
|
||||
#endif ///(defined RFCOMM_INCLUDED && RFCOMM_INCLUDED == TRUE)
|
||||
|
Reference in New Issue
Block a user