Skip to content

Commit

Permalink
cleanup: skip a do_gc iteration before removing peers marked for dele…
Browse files Browse the repository at this point in the history
…tion

This fixes an issue with events where we try to make queries on peers
that no longer exist internally
  • Loading branch information
JFreegman committed Jan 16, 2024
1 parent 16809dc commit 21a8ff5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion other/bootstrap_daemon/docker/tox-bootstrapd.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0b58b866f87d92267db4577d26eebe10dcf5a96ff53ac5a863dade83f471961c /usr/local/bin/tox-bootstrapd
738c98673260593fc150b8d5b0cb770cd521f469b4eb04c873f19d89bb7238cf /usr/local/bin/tox-bootstrapd
31 changes: 19 additions & 12 deletions toxcore/group_chats.c
Original file line number Diff line number Diff line change
Expand Up @@ -6995,23 +6995,30 @@ non_null(1, 2) nullable(3)
static void do_peer_delete(const GC_Session *c, GC_Chat *chat, void *userdata)
{
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);

if (gconn->pending_delete) {
const GC_Exit_Info *exit_info = &gconn->exit_info;
if (!gconn->pending_delete) {
continue;
}

if (exit_info->exit_type == GC_EXIT_TYPE_TIMEOUT && gconn->confirmed) {
add_gc_peer_timeout_list(chat, gconn);
}
if (!gconn->delete_this_iteration) {
gconn->delete_this_iteration = true;
continue;
}

if (!peer_delete(c, chat, i, userdata)) {
LOGGER_ERROR(chat->log, "Failed to delete peer %u", i);
}
const GC_Exit_Info *exit_info = &gconn->exit_info;

if (i >= chat->numpeers) {
break;
}
if (exit_info->exit_type == GC_EXIT_TYPE_TIMEOUT && gconn->confirmed) {
add_gc_peer_timeout_list(chat, gconn);

Check warning on line 7013 in toxcore/group_chats.c

View check run for this annotation

Codecov / codecov/patch

toxcore/group_chats.c#L7013

Added line #L7013 was not covered by tests
}

if (!peer_delete(c, chat, i, userdata)) {
LOGGER_ERROR(chat->log, "Failed to delete peer %u", i);

Check warning on line 7017 in toxcore/group_chats.c

View check run for this annotation

Codecov / codecov/patch

toxcore/group_chats.c#L7017

Added line #L7017 was not covered by tests
}

if (i >= chat->numpeers) {
break;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions toxcore/group_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ typedef struct GC_Connection {
bool pending_key_rotation_request;

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_Connection;

Expand Down

0 comments on commit 21a8ff5

Please sign in to comment.