Merge ea305cb805e26d0d581cac444803ee9ce5ae592e into 83e8f70ee4f7ddb6b874bdb81a1f75ceeeba58e4

This commit is contained in:
tgotic 2025-03-01 09:15:04 +00:00 committed by GitHub
commit 7d7490b27b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 20 additions and 6 deletions

View File

@ -222,7 +222,7 @@ extern void bta_sys_register(UINT8 id, const tBTA_SYS_REG *p_reg);
extern void bta_sys_deregister(UINT8 id); extern void bta_sys_deregister(UINT8 id);
extern BOOLEAN bta_sys_is_register(UINT8 id); extern BOOLEAN bta_sys_is_register(UINT8 id);
extern UINT16 bta_sys_get_sys_features(void); extern UINT16 bta_sys_get_sys_features(void);
extern void bta_sys_sendmsg(void *p_msg); extern BOOLEAN bta_sys_sendmsg(void *p_msg);
extern void bta_sys_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, INT32 timeout_ms); extern void bta_sys_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, INT32 timeout_ms);
extern void bta_sys_stop_timer(TIMER_LIST_ENT *p_tle); extern void bta_sys_stop_timer(TIMER_LIST_ENT *p_tle);
extern void bta_sys_free_timer(TIMER_LIST_ENT *p_tle); extern void bta_sys_free_timer(TIMER_LIST_ENT *p_tle);

View File

@ -1160,8 +1160,9 @@ tBTA_JV_STATUS BTA_JvRfcommWrite(UINT32 handle, UINT32 req_id, int len, UINT8 *p
p_msg->p_data = p_data; p_msg->p_data = p_data;
p_msg->len = len; p_msg->len = len;
APPL_TRACE_API( "write ok"); APPL_TRACE_API( "write ok");
bta_sys_sendmsg(p_msg); if (bta_sys_sendmsg(p_msg)) {
status = BTA_JV_SUCCESS; status = BTA_JV_SUCCESS;
}
} }
return (status); return (status);
} }

View File

@ -564,10 +564,10 @@ BOOLEAN bta_sys_is_register(UINT8 id)
** API functions and call-in functions. ** API functions and call-in functions.
** **
** **
** Returns void ** Returns true if message is posted to BTA, false otherwise
** **
*******************************************************************************/ *******************************************************************************/
void bta_sys_sendmsg(void *p_msg) BOOLEAN bta_sys_sendmsg(void *p_msg)
{ {
// There is a race condition that occurs if the stack is shut down while // There is a race condition that occurs if the stack is shut down while
// there is a procedure in progress that can schedule a task via this // there is a procedure in progress that can schedule a task via this
@ -575,7 +575,9 @@ void bta_sys_sendmsg(void *p_msg)
// it gets used here; hence we check for NULL before using it. // it gets used here; hence we check for NULL before using it.
if (btu_task_post(SIG_BTU_BTA_MSG, p_msg, OSI_THREAD_MAX_TIMEOUT) == false) { if (btu_task_post(SIG_BTU_BTA_MSG, p_msg, OSI_THREAD_MAX_TIMEOUT) == false) {
osi_free(p_msg); osi_free(p_msg);
return FALSE;
} }
return TRUE;
} }
/******************************************************************************* /*******************************************************************************

View File

@ -908,7 +908,12 @@ static void btc_spp_write(btc_spp_args_t *arg)
} }
} else { } else {
if (fixed_queue_enqueue(slot->tx.queue, arg->write.p_data, 0)) { if (fixed_queue_enqueue(slot->tx.queue, arg->write.p_data, 0)) {
BTA_JvRfcommWrite(arg->write.handle, slot->id, arg->write.len, arg->write.p_data); if (BTA_JvRfcommWrite(arg->write.handle, slot->id, arg->write.len, arg->write.p_data) == BTA_JV_SUCCESS) {
arg->write.p_data = NULL; // arg->write.p_data passed to tBTA_JV_API_RFCOMM_WRITE::p_data, set it to NULL to prevent freeing
} else {
arg->write.p_data = fixed_queue_try_remove_from_queue(slot->tx.queue, arg->write.p_data);
ret = ESP_SPP_FAILURE;
}
} else { } else {
ret = ESP_SPP_NO_RESOURCE; ret = ESP_SPP_NO_RESOURCE;
} }
@ -968,6 +973,12 @@ void btc_spp_arg_deep_free(btc_msg_t *msg)
osi_free(arg->start_discovery.p_uuid_list); osi_free(arg->start_discovery.p_uuid_list);
} }
break; break;
case BTC_SPP_ACT_WRITE:
if (arg->write.p_data) {
osi_free(arg->write.p_data);
arg->write.p_data = NULL;
}
break;
default: default:
break; break;
} }