修复了网络参数的保存逻辑

This commit is contained in:
2026-09-10 14:21:07 +08:00
parent 8e1fd3b2b8
commit ca1dc980d1
24 changed files with 1457 additions and 72 deletions
+12
View File
@@ -114,6 +114,9 @@ void time_sync_task(void *argument) {
}
for (;;) {
/* 记录本次监听对应的网络代次;代次变化(网络重建)则放弃旧监听重建 */
uint32_t gen = net_get_generation();
int ls = time_sync_open_listener();
if (ls < 0) {
DBG_ERROR("time_sync: open listener FAIL, retry later");
@@ -126,10 +129,19 @@ void time_sync_task(void *argument) {
do {
conn = net_accept(ls, NULL, NULL);
if (conn < 0) {
if (net_get_generation() != gen) {
net_close(ls); /* 网络重建:旧监听失效,回外层重建 */
break;
}
vTaskDelay(pdMS_TO_TICKS(200));
}
} while (conn < 0);
if (conn < 0) {
DBG_INFO("time_sync: network re-init, relisten");
continue;
}
time_sync_handle_conn(conn);
/* conn(单连接模式下即 ls)已被 net_close 释放,下次循环重建监听 */