From: hcj <1224667075@qq.com> Date: Thu, 3 Jul 2025 06:43:01 +0000 (+0800) Subject: 修改 lwip 协议栈 useg被异常释放导致死机问题 仅简单屏蔽,待后续验证 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=48ae63a3a41ce7bf83cf53b042c654f0f7c60223;p=mirrors%2FFD230.git 修改 lwip 协议栈 useg被异常释放导致死机问题 仅简单屏蔽,待后续验证 --- diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c index 9a020b824..24a9452d9 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c @@ -49,6 +49,8 @@ extern "C" { #include "custom_save_runtime.h" #include "aivoice/include/AiVoiceModelC.h" #include "voice_call_volte_sample_wrapper.h" +#include "cat1_ws.h" + // extern void bts_data_to_uuid_len2(uint16_t uuid_data, bt_uuid_t *out_uuid); // extern void bts_init_128bit_uuid(const bt_uuid_t *uuid); // #include "ble_hid_take_photo_server.h" diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/bk_websocket.h b/code/sdk/drivers/peripheral/slip/cat1Service/bk_websocket.h index 753610021..a706fe7fe 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/bk_websocket.h +++ b/code/sdk/drivers/peripheral/slip/cat1Service/bk_websocket.h @@ -32,10 +32,7 @@ void close_websocket_client(WebSocketClient *client) ; int receive_websocket_message(WebSocketClient *client, unsigned char *buf,int len,WebSocketMessageType *code); // 发送 WebSocket 消息 -int send_websocket_message(WebSocketClient *client, const unsigned char *message, size_t message_len, WebSocketMessageType type) ; +// int send_websocket_message(WebSocketClient *client, uint8_t *message, size_t message_len, WebSocketMessageType type) ; -void send_ai_bin(char *buf,uint32_t len); - -void uapi_start_asr(); #endif diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_at_cmd.cpp b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_at_cmd.cpp index 9e4561c5e..5391356b2 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_at_cmd.cpp +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_at_cmd.cpp @@ -26,7 +26,7 @@ extern "C" { #define PPG_FAILED (-1) #include "app_at_process.h" -#include "bk_websocket.h" +#include "cat1_ws.h" static int ConvertCmdToParam(uint8_t *para, uint32_t paraLen, diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.cpp b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.cpp index 58ca34091..318ac829f 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.cpp +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.cpp @@ -475,7 +475,7 @@ int send_handshake(WebSocketClient *client,const char *headers) { // 发送 WebSocket 消息 -int send_websocket_message(WebSocketClient *client, const unsigned char *message, size_t message_len, WebSocketMessageType type) { +int send_websocket_message(WebSocketClient *client, uint8_t *message, size_t message_len, WebSocketMessageType type) { if(client==NULL||message==NULL ) { @@ -989,7 +989,7 @@ void send_ai_txt(uint8_t type,char *msg) return; } - if (send_websocket_message(chat_client,( const unsigned char *)jsonString,strlen(jsonString),WS_TEXT)==0) + if (send_websocket_message(chat_client,( uint8_t *)jsonString,strlen(jsonString),WS_TEXT)==0) WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"send_websocket_message succ 0\n"); else { @@ -1234,7 +1234,7 @@ void uapi_start_asr(void) char *jsonString = "{\"header\":{\"event\":\"StartTranscription\",\"trace_id\": \ \"3fa6b9e6a30b407ea38ad7ae69e6c291\"},\"payload\":{\"format\":\"MP3\",\"sample_rate\":16000}}"; - if (send_websocket_message(asr_client,( const unsigned char *)jsonString,strlen(jsonString),WS_TEXT)==0) + if (send_websocket_message(asr_client,( uint8_t *)jsonString,strlen(jsonString),WS_TEXT)==0) WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"send_websocket_message succ 0\n"); else { @@ -1275,7 +1275,7 @@ void uapi_stop_asr(void) // uapi_tts_paly_init(); - if (send_websocket_message(asr_client,( const unsigned char *)jsonString,strlen(jsonString),WS_TEXT)==0) + if (send_websocket_message(asr_client,( uint8_t *)jsonString,strlen(jsonString),WS_TEXT)==0) WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"send_websocket_message succ 0\n"); else { @@ -1289,11 +1289,11 @@ void uapi_stop_asr(void) -void send_ai_bin(char *buf,uint32_t len) +void send_ai_bin(uint8_t *buf,uint32_t len) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"send_ai_bin %d\n",len); - if (send_websocket_message(asr_client,( const unsigned char *)buf,len,WS_BINARY)==0) + if (send_websocket_message(asr_client,( uint8_t *)buf,len,WS_BINARY)==0) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"send_websocket_message succ 0\n"); bk_sleep(100); @@ -1702,7 +1702,7 @@ void uapi_start_tts(void) printf("uapi_start_tts : %s\r\n",jsonString); - if (send_websocket_message(tts_client,( const unsigned char *)jsonString,strlen(jsonString),WS_TEXT)==0) + if (send_websocket_message(tts_client,( uint8_t *)jsonString,strlen(jsonString),WS_TEXT)==0) WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"send_websocket_message succ 0\n"); } void uapi_start_tts_single(void) @@ -1724,7 +1724,7 @@ void uapi_start_tts_single(void) printf("uapi_start_tts : %s\r\n",jsonString); - if (send_websocket_message(tts_client,( const unsigned char *)jsonString,strlen(jsonString),WS_TEXT)==0) + if (send_websocket_message(tts_client,(uint8_t *)jsonString,strlen(jsonString),WS_TEXT)==0) WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"send_websocket_message succ 0\n"); } @@ -1748,7 +1748,7 @@ void uapi_start_tts_single(void) printf("uapi_start_tts : %s\r\n",jsonString); - if (send_websocket_message(tts_client,( const unsigned char *)jsonString,strlen(jsonString),WS_TEXT)==0) + if (send_websocket_message(tts_client,( uint8_t *)jsonString,strlen(jsonString),WS_TEXT)==0) WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"send_websocket_message succ 0\n"); free(jsonString); @@ -1772,7 +1772,7 @@ void send_tts_txt(char *msg) }"; - if (send_websocket_message(tts_client,( const unsigned char *)jsonString,strlen(jsonString),WS_TEXT)==0) + if (send_websocket_message(tts_client,( uint8_t *)jsonString,strlen(jsonString),WS_TEXT)==0) WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"send_websocket_message succ 0\n"); else WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"send_websocket_message fail 1\n"); @@ -2020,19 +2020,19 @@ int32_t uapi_tts_paly_stop(void) void asr_server_deinit(void) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"WS_CLOSE"); - send_websocket_message(asr_client,(const unsigned char *)"WS_CLOSE",strlen("WS_CLOSE"),WS_CLOSE); + send_websocket_message(asr_client,(uint8_t *)"WS_CLOSE",strlen("WS_CLOSE"),WS_CLOSE); } void chat_server_deinit(void) { - send_websocket_message(chat_client,(const unsigned char *)"WS_CLOSE",strlen("WS_CLOSE"),WS_CLOSE); + send_websocket_message(chat_client,(uint8_t *)"WS_CLOSE",strlen("WS_CLOSE"),WS_CLOSE); } void tts_server_deinit(void) { - send_websocket_message(tts_client,(const unsigned char *)"WS_CLOSE",strlen("WS_CLOSE"),WS_CLOSE); + send_websocket_message(tts_client,(uint8_t *)"WS_CLOSE",strlen("WS_CLOSE"),WS_CLOSE); } diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.h b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.h index a7a8a7cbc..daa3dfb62 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.h +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_ws.h @@ -37,6 +37,11 @@ void uapi_start_asr_task(void); void asr_record_test(void); +void send_ai_bin(uint8_t *buf,uint32_t len); + +void uapi_start_asr(void); + + diff --git a/code/sdk/open_source/openharmony/third_party/lwip/src/core/tcp_out.c b/code/sdk/open_source/openharmony/third_party/lwip/src/core/tcp_out.c index b9077a0ea..e7418e4f7 100644 --- a/code/sdk/open_source/openharmony/third_party/lwip/src/core/tcp_out.c +++ b/code/sdk/open_source/openharmony/third_party/lwip/src/core/tcp_out.c @@ -1393,7 +1393,47 @@ tcp_output(struct tcp_pcb *pcb) /* In the case of fast retransmit, the packet should not go to the tail * of the unacked queue, but rather somewhere before it. We need to check for * this case. -STJ Jul 27, 2004 */ + // printf(" tcp_output_segment \r\n"); + //////////////////////////////////////////////////////////////////////////////////////////////// + /* + useg 被异常释放造成死机 , 后续待验证 + */ + if(seg==NULL) + { + printf("tcp_output_segment seg==NULL\r\n"); + return ERR_MEM; + } + + if(seg->tcphdr==NULL) + { + printf("tcp_output_segment seg->tcphdr=NULL\r\n"); + return ERR_MEM; + } + if(seg->tcphdr->seqno==NULL) + { + printf("tcp_output_segment seg->tcphdr->seqno==NULL\r\n"); + return ERR_MEM; + } + + if(useg==NULL) + { + printf("tcp_output_segment useg==NULL \r\n"); + return ERR_MEM; + } + + if(useg->tcphdr==NULL) + { + printf("tcp_output_segment useg->tcphdr=NULL\r\n"); + return ERR_MEM; + } + if(useg->tcphdr->seqno==NULL) + { + printf(" tcp_output_segment useg->tcphdr->seqno==NULL\r\n"); + return ERR_MEM; + } if (TCP_SEQ_LT(lwip_ntohl(seg->tcphdr->seqno), lwip_ntohl(useg->tcphdr->seqno))) { + + /* add segment to before tail of unacked list, keeping the list sorted */ struct tcp_seg **cur_seg = &(pcb->unacked); while (*cur_seg &&