fix(bt): fix l2cap malloc fail in throughput test
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
#define VFS_CLOSE_TIMEOUT (20 * 1000)
|
||||
#define BTC_L2CAP_ROLE_MASTER 0
|
||||
#define BTC_L2CAP_ROLE_SLAVE 1
|
||||
#define BTC_L2CAP_RX_MTU (990)
|
||||
|
||||
typedef struct {
|
||||
bool peer_fc; /* true if flow control is set based on peer's request */
|
||||
@@ -101,10 +102,10 @@ static const tL2CAP_ERTM_INFO obex_l2c_etm_opt =
|
||||
{
|
||||
L2CAP_FCR_ERTM_MODE, /* Mandatory for OBEX over l2cap */
|
||||
L2CAP_FCR_CHAN_OPT_ERTM, /* Mandatory for OBEX over l2cap */
|
||||
OBX_USER_RX_POOL_ID,
|
||||
OBX_USER_TX_POOL_ID,
|
||||
OBX_FCR_RX_POOL_ID,
|
||||
OBX_FCR_TX_POOL_ID
|
||||
L2CAP_USER_RX_BUF_SIZE,
|
||||
L2CAP_USER_TX_BUF_SIZE,
|
||||
L2CAP_FCR_RX_BUF_SIZE,
|
||||
L2CAP_FCR_TX_BUF_SIZE
|
||||
};
|
||||
|
||||
#if L2CAP_DYNAMIC_MEMORY == FALSE
|
||||
@@ -553,7 +554,7 @@ static void btc_l2cap_start_srv(btc_l2cap_args_t *arg)
|
||||
cfg.fcr_present = TRUE;
|
||||
cfg.fcr = obex_l2c_fcr_opts_def;
|
||||
BTA_JvL2capStartServer(slot->security, slot->role, &obex_l2c_etm_opt, slot->psm,
|
||||
L2CAP_MAX_SDU_LENGTH, &cfg, (tBTA_JV_L2CAP_CBACK *)btc_l2cap_inter_cb, (void *)slot->id);
|
||||
BTC_L2CAP_RX_MTU, &cfg, (tBTA_JV_L2CAP_CBACK *)btc_l2cap_inter_cb, (void *)slot->id);
|
||||
osi_mutex_unlock(&l2cap_local_param.l2cap_slot_mutex);
|
||||
} while(0);
|
||||
|
||||
@@ -694,7 +695,7 @@ static void btc_l2cap_connect(btc_l2cap_args_t *arg)
|
||||
cfg.fcr = obex_l2c_fcr_opts_def;
|
||||
|
||||
BTA_JvL2capConnect(slot->security, slot->role, &obex_l2c_etm_opt, slot->psm,
|
||||
L2CAP_MAX_SDU_LENGTH, &cfg, slot->addr, (tBTA_JV_L2CAP_CBACK *)btc_l2cap_inter_cb, (void *)slot->id);
|
||||
BTC_L2CAP_RX_MTU, &cfg, slot->addr, (tBTA_JV_L2CAP_CBACK *)btc_l2cap_inter_cb, (void *)slot->id);
|
||||
osi_mutex_unlock(&l2cap_local_param.l2cap_slot_mutex);
|
||||
} while (0);
|
||||
|
||||
|
||||
@@ -2112,7 +2112,7 @@
|
||||
* in basic and streaming modes. Range: 1 - 63
|
||||
*/
|
||||
#ifndef OBX_FCR_OPT_TX_WINDOW_SIZE_BR_EDR
|
||||
#define OBX_FCR_OPT_TX_WINDOW_SIZE_BR_EDR 20
|
||||
#define OBX_FCR_OPT_TX_WINDOW_SIZE_BR_EDR 10
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
@@ -510,18 +510,19 @@ UINT16 GAP_ConnWriteData (UINT16 gap_handle, UINT8 *p_data, UINT16 max_len, UINT
|
||||
}
|
||||
|
||||
while (max_len) {
|
||||
UINT16 length = (p_ccb->rem_mtu_size < max_len) ? p_ccb->rem_mtu_size : max_len;
|
||||
if (p_ccb->cfg.fcr.mode == L2CAP_FCR_ERTM_MODE) {
|
||||
if ((p_buf = (BT_HDR *)osi_malloc(L2CAP_FCR_ERTM_BUF_SIZE)) == NULL) {
|
||||
if ((p_buf = (BT_HDR *)osi_malloc(BT_HDR_SIZE + length + L2CAP_MIN_OFFSET + L2CAP_FCS_LEN)) == NULL) {
|
||||
return (GAP_ERR_CONGESTED);
|
||||
}
|
||||
} else {
|
||||
if ((p_buf = (BT_HDR *)osi_malloc(GAP_DATA_BUF_SIZE)) == NULL) {
|
||||
if ((p_buf = (BT_HDR *)osi_malloc(BT_HDR_SIZE + length + L2CAP_MIN_OFFSET)) == NULL) {
|
||||
return (GAP_ERR_CONGESTED);
|
||||
}
|
||||
}
|
||||
|
||||
p_buf->offset = L2CAP_MIN_OFFSET;
|
||||
p_buf->len = (p_ccb->rem_mtu_size < max_len) ? p_ccb->rem_mtu_size : max_len;
|
||||
p_buf->len = length;
|
||||
p_buf->event = BT_EVT_TO_BTU_SP_DATA;
|
||||
|
||||
memcpy ((UINT8 *)(p_buf + 1) + p_buf->offset, p_data, p_buf->len);
|
||||
|
||||
Reference in New Issue
Block a user