mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/buff_semaphore_not_free' into 'master'
component/bt: Fixed ble memory leak issue, buff_semaphore was not released. See merge request espressif/esp-idf!9507
This commit is contained in:
commit
7639f20fa5
@ -2274,7 +2274,6 @@ UINT16 L2CA_FlushChannel (UINT16 lcid, UINT16 num_to_flush)
|
||||
return (num_left);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Function update_acl_pkt_num
|
||||
@ -2284,7 +2283,6 @@ UINT16 L2CA_FlushChannel (UINT16 lcid, UINT16 num_to_flush)
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
void l2ble_update_att_acl_pkt_num(UINT8 type, tl2c_buff_param_t *param)
|
||||
{
|
||||
@ -2292,28 +2290,38 @@ void l2ble_update_att_acl_pkt_num(UINT8 type, tl2c_buff_param_t *param)
|
||||
static INT16 btc_buf;
|
||||
static INT16 btu_buf;
|
||||
|
||||
if(buff_semaphore != NULL){
|
||||
xSemaphoreTake(buff_semaphore, 10 / portTICK_PERIOD_MS);
|
||||
if(buff_semaphore == NULL && type != L2CA_BUFF_INI){
|
||||
L2CAP_TRACE_ERROR("%s buff_semaphore not init", __func__);
|
||||
return;
|
||||
}
|
||||
switch (type)
|
||||
{
|
||||
case L2CA_ADD_BTC_NUM:{
|
||||
xSemaphoreTake(buff_semaphore, portMAX_DELAY);
|
||||
btc_buf ++;
|
||||
xSemaphoreGive(buff_semaphore);
|
||||
break;
|
||||
}
|
||||
case L2CA_DECREASE_BTC_NUM:{
|
||||
xSemaphoreTake(buff_semaphore, portMAX_DELAY);
|
||||
btc_buf --;
|
||||
xSemaphoreGive(buff_semaphore);
|
||||
break;
|
||||
}
|
||||
case L2CA_ADD_BTU_NUM:{
|
||||
xSemaphoreTake(buff_semaphore, portMAX_DELAY);
|
||||
btu_buf ++;
|
||||
xSemaphoreGive(buff_semaphore);
|
||||
break;
|
||||
}
|
||||
case L2CA_DECREASE_BTU_NUM:{
|
||||
xSemaphoreTake(buff_semaphore, portMAX_DELAY);
|
||||
btu_buf --;
|
||||
xSemaphoreGive(buff_semaphore);
|
||||
break;
|
||||
}
|
||||
case L2CA_GET_ATT_NUM:{
|
||||
xSemaphoreTake(buff_semaphore, portMAX_DELAY);
|
||||
INT16 att_acl_pkt_num = 0;
|
||||
INT16 att_max_num = 0;
|
||||
*(param->get_num) = 0;
|
||||
@ -2321,17 +2329,20 @@ void l2ble_update_att_acl_pkt_num(UINT8 type, tl2c_buff_param_t *param)
|
||||
tGATT_TCB * p_tcb = gatt_get_tcb_by_idx(tcb_idx);
|
||||
if (p_tcb == NULL){
|
||||
L2CAP_TRACE_ERROR("%s not found p_tcb", __func__);
|
||||
xSemaphoreGive(buff_semaphore);
|
||||
break;
|
||||
}
|
||||
tL2C_LCB * p_lcb = l2cu_find_lcb_by_bd_addr (p_tcb->peer_bda, BT_TRANSPORT_LE);
|
||||
if (p_lcb == NULL){
|
||||
L2CAP_TRACE_ERROR("%s not found p_lcb", __func__);
|
||||
xSemaphoreGive(buff_semaphore);
|
||||
break;
|
||||
}
|
||||
fixed_queue_t * queue = p_lcb->p_fixed_ccbs[L2CAP_ATT_CID - L2CAP_FIRST_FIXED_CHNL]->xmit_hold_q;
|
||||
att_max_num = MIN(p_lcb->link_xmit_quota, L2CAP_CACHE_ATT_ACL_NUM);
|
||||
if (queue == NULL){
|
||||
L2CAP_TRACE_ERROR("%s not found queue", __func__);
|
||||
xSemaphoreGive(buff_semaphore);
|
||||
break;
|
||||
}
|
||||
att_acl_pkt_num = fixed_queue_length(queue);
|
||||
@ -2340,23 +2351,31 @@ void l2ble_update_att_acl_pkt_num(UINT8 type, tl2c_buff_param_t *param)
|
||||
*(param->get_num) = att_max_num - att_acl_pkt_num - (btc_buf + btu_buf);
|
||||
}
|
||||
}
|
||||
xSemaphoreGive(buff_semaphore);
|
||||
break;
|
||||
}
|
||||
case L2CA_BUFF_INI:{
|
||||
btc_buf = 0;
|
||||
btu_buf = 0;
|
||||
buff_semaphore = xSemaphoreCreateBinary();
|
||||
if (buff_semaphore == NULL) {
|
||||
L2CAP_TRACE_ERROR("%s NO MEMORY", __func__);
|
||||
break;
|
||||
}
|
||||
xSemaphoreGive(buff_semaphore);
|
||||
break;
|
||||
}
|
||||
case L2CA_BUFF_DEINIT:{
|
||||
xSemaphoreTake(buff_semaphore, portMAX_DELAY);
|
||||
btc_buf = 0;
|
||||
btu_buf = 0;
|
||||
xSemaphoreGive(buff_semaphore);
|
||||
vSemaphoreDelete(buff_semaphore);
|
||||
buff_semaphore = NULL;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
xSemaphoreGive(buff_semaphore);
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user