diff --git a/src/chat/chat_sync.c b/src/chat/chat_sync.c index 03c2ec93..7ab95966 100644 --- a/src/chat/chat_sync.c +++ b/src/chat/chat_sync.c @@ -786,6 +786,12 @@ int chat_sync_init(struct UTUN_INSTANCE* inst) { chat_admin_init(inst); chat_join_init(inst); + /* После restart транспорт может уже быть UP: нового conn_up не будет. */ + if (cs->channel_count) { + cs_schedule_sync(cs); + DEBUG_INFO(DEBUG_CATEGORY_MEMBER_SYNC, "%s: initial member sync scheduled channels=%d", CS_ID, cs->channel_count); + } + DEBUG_INFO(DEBUG_CATEGORY_MEMBER_SYNC, "%s: initialized", CS_ID); return 0; } diff --git a/tests/test_chat_poll_network.c b/tests/test_chat_poll_network.c index 0c9ca367..710de69b 100644 --- a/tests/test_chat_poll_network.c +++ b/tests/test_chat_poll_network.c @@ -70,7 +70,8 @@ static struct NODE_CONN_DIRECT* connect_node(int from, int to, unsigned port) { } static int wait_ready(struct TOPO_PEER_REQUEST* handle) { - for (int i = 0; i < 3000; i++) { + uint64_t deadline = get_time_tb() + 15u * 10000u; + while (get_time_tb() < deadline) { if (topo_group_peer_phase(handle) == TOPO_PEER_READY) return 1; uasync_poll(ua, 5); } @@ -80,7 +81,8 @@ static int wait_ready(struct TOPO_PEER_REQUEST* handle) { /* C открывает групповой запрос после входящего UP; до него адрес B ещё не получен. */ static int wait_transport(struct NODE_CONN_DIRECT* ab, struct NODE_CONN_DIRECT* bc) { struct ETCP_CONN *a = NULL, *b = NULL; - for (int i = 0; i < 3000; i++) { + uint64_t deadline = get_time_tb() + 15u * 10000u; + while (get_time_tb() < deadline) { a = node_conn_direct_get_conn(ab); b = node_conn_direct_get_conn(bc); struct ETCP_CONN* c = instance_find_conn(nodes[2], nodes[1]->node_id); if (a && b && c && a->initialized && b->initialized && c->initialized @@ -97,7 +99,8 @@ static sqlite3_int64 field(struct UTUN_INSTANCE* inst, const char* json, const c } static int wait_result(int index, int voters, int option_one, int reactions) { - for (int i = 0; i < 3000; i++) { + uint64_t deadline = get_time_tb() + 15u * 10000u; + while (get_time_tb() < deadline) { char* result = NULL; if (chat_feedback_snapshot(nodes[index], channel, message_id, &result) == 0) { int ok = !field(nodes[index], result, "$.pending") && field(nodes[index], result, "$.poll.voters") == voters