Skip to content

Commit 21a8ff5

Browse files
committed
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
1 parent 16809dc commit 21a8ff5

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0b58b866f87d92267db4577d26eebe10dcf5a96ff53ac5a863dade83f471961c /usr/local/bin/tox-bootstrapd
1+
738c98673260593fc150b8d5b0cb770cd521f469b4eb04c873f19d89bb7238cf /usr/local/bin/tox-bootstrapd

toxcore/group_chats.c

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6995,23 +6995,30 @@ non_null(1, 2) nullable(3)
69956995
static void do_peer_delete(const GC_Session *c, GC_Chat *chat, void *userdata)
69966996
{
69976997
for (uint32_t i = 1; i < chat->numpeers; ++i) {
6998-
const GC_Connection *gconn = get_gc_connection(chat, i);
6998+
GC_Connection *gconn = get_gc_connection(chat, i);
69996999
assert(gconn != nullptr);
70007000

7001-
if (gconn->pending_delete) {
7002-
const GC_Exit_Info *exit_info = &gconn->exit_info;
7001+
if (!gconn->pending_delete) {
7002+
continue;
7003+
}
70037004

7004-
if (exit_info->exit_type == GC_EXIT_TYPE_TIMEOUT && gconn->confirmed) {
7005-
add_gc_peer_timeout_list(chat, gconn);
7006-
}
7005+
if (!gconn->delete_this_iteration) {
7006+
gconn->delete_this_iteration = true;
7007+
continue;
7008+
}
70077009

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

7012-
if (i >= chat->numpeers) {
7013-
break;
7014-
}
7012+
if (exit_info->exit_type == GC_EXIT_TYPE_TIMEOUT && gconn->confirmed) {
7013+
add_gc_peer_timeout_list(chat, gconn);
7014+
}
7015+
7016+
if (!peer_delete(c, chat, i, userdata)) {
7017+
LOGGER_ERROR(chat->log, "Failed to delete peer %u", i);
7018+
}
7019+
7020+
if (i >= chat->numpeers) {
7021+
break;
70157022
}
70167023
}
70177024
}

toxcore/group_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ typedef struct GC_Connection {
133133
bool pending_key_rotation_request;
134134

135135
bool pending_delete; /* true if this peer has been marked for deletion */
136+
bool delete_this_iteration; /* true if this peer should be deleted this do_gc() iteration*/
136137
GC_Exit_Info exit_info;
137138
} GC_Connection;
138139

0 commit comments

Comments
 (0)