cleanup: skip a do_gc iteration before removing peers marked for deletion

This fixes an issue with events where we try to make queries on peers
that no longer exist internally
This commit is contained in:
jfreegman 2024-01-16 13:11:52 -05:00
parent 16809dc36e
commit 21a8ff5895
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63
3 changed files with 21 additions and 13 deletions

View File

@ -1 +1 @@
0b58b866f87d92267db4577d26eebe10dcf5a96ff53ac5a863dade83f471961c /usr/local/bin/tox-bootstrapd 738c98673260593fc150b8d5b0cb770cd521f469b4eb04c873f19d89bb7238cf /usr/local/bin/tox-bootstrapd

View File

@ -6995,23 +6995,30 @@ non_null(1, 2) nullable(3)
static void do_peer_delete(const GC_Session *c, GC_Chat *chat, void *userdata) static void do_peer_delete(const GC_Session *c, GC_Chat *chat, void *userdata)
{ {
for (uint32_t i = 1; i < chat->numpeers; ++i) { for (uint32_t i = 1; i < chat->numpeers; ++i) {
const GC_Connection *gconn = get_gc_connection(chat, i); GC_Connection *gconn = get_gc_connection(chat, i);
assert(gconn != nullptr); assert(gconn != nullptr);
if (gconn->pending_delete) { if (!gconn->pending_delete) {
const GC_Exit_Info *exit_info = &gconn->exit_info; continue;
}
if (exit_info->exit_type == GC_EXIT_TYPE_TIMEOUT && gconn->confirmed) { if (!gconn->delete_this_iteration) {
add_gc_peer_timeout_list(chat, gconn); gconn->delete_this_iteration = true;
} continue;
}
if (!peer_delete(c, chat, i, userdata)) { const GC_Exit_Info *exit_info = &gconn->exit_info;
LOGGER_ERROR(chat->log, "Failed to delete peer %u", i);
}
if (i >= chat->numpeers) { if (exit_info->exit_type == GC_EXIT_TYPE_TIMEOUT && gconn->confirmed) {
break; add_gc_peer_timeout_list(chat, gconn);
} }
if (!peer_delete(c, chat, i, userdata)) {
LOGGER_ERROR(chat->log, "Failed to delete peer %u", i);
}
if (i >= chat->numpeers) {
break;
} }
} }
} }

View File

@ -133,6 +133,7 @@ typedef struct GC_Connection {
bool pending_key_rotation_request; bool pending_key_rotation_request;
bool pending_delete; /* true if this peer has been marked for deletion */ bool pending_delete; /* true if this peer has been marked for deletion */
bool delete_this_iteration; /* true if this peer should be deleted this do_gc() iteration*/
GC_Exit_Info exit_info; GC_Exit_Info exit_info;
} GC_Connection; } GC_Connection;