Browse Source

Restart member and feedback synchronization over existing transports

master
evgeny 5 days ago
parent
commit
bbc8b7693a
  1. 6
      src/chat/chat_sync.c
  2. 9
      tests/test_chat_poll_network.c

6
src/chat/chat_sync.c

@ -786,6 +786,12 @@ int chat_sync_init(struct UTUN_INSTANCE* inst) {
chat_admin_init(inst); chat_admin_init(inst);
chat_join_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); DEBUG_INFO(DEBUG_CATEGORY_MEMBER_SYNC, "%s: initialized", CS_ID);
return 0; return 0;
} }

9
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) { 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; if (topo_group_peer_phase(handle) == TOPO_PEER_READY) return 1;
uasync_poll(ua, 5); uasync_poll(ua, 5);
} }
@ -80,7 +81,8 @@ static int wait_ready(struct TOPO_PEER_REQUEST* handle) {
/* C открывает групповой запрос после входящего UP; до него адрес B ещё не получен. */ /* C открывает групповой запрос после входящего UP; до него адрес B ещё не получен. */
static int wait_transport(struct NODE_CONN_DIRECT* ab, struct NODE_CONN_DIRECT* bc) { static int wait_transport(struct NODE_CONN_DIRECT* ab, struct NODE_CONN_DIRECT* bc) {
struct ETCP_CONN *a = NULL, *b = NULL; 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); 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); struct ETCP_CONN* c = instance_find_conn(nodes[2], nodes[1]->node_id);
if (a && b && c && a->initialized && b->initialized && c->initialized 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) { 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; char* result = NULL;
if (chat_feedback_snapshot(nodes[index], channel, message_id, &result) == 0) { 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 int ok = !field(nodes[index], result, "$.pending") && field(nodes[index], result, "$.poll.voters") == voters

Loading…
Cancel
Save