修复了网络参数的保存逻辑
This commit is contained in:
@@ -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 释放,下次循环重建监听 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user