Skip to content

Commit

Permalink
replicator: fixed infinity loop on sync replication
Browse files Browse the repository at this point in the history
Before this fix, replicator adds the same lookup into callbacks over and
over, until it reaches out of memory, and crashes.

This regression was introduced 447e086
with initial implementation of replicator.
  • Loading branch information
catap committed Sep 25, 2024
1 parent 1fd4fcc commit 44803b8
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/replication/replicator/replicator-queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,15 +321,14 @@ replicator_queue_handle_sync_lookups(struct replicator_queue *queue,

t_array_init(&callbacks, 8);
lookups = array_get_modifiable(&queue->sync_lookups, &count);
for (i = 0; i < count; ) {
for (i = 0; i < count; i++) {
if (lookups[i].user != user)
i++;
else if (lookups[i].wait_for_next_push) {
continue;
if (lookups[i].wait_for_next_push) {
/* another sync request came while user was being
replicated */
i_assert(user->priority == REPLICATION_PRIORITY_SYNC);
lookups[i].wait_for_next_push = FALSE;
i++;
} else {
array_push_back(&callbacks, &lookups[i]);
array_delete(&queue->sync_lookups, i, 1);
Expand Down

0 comments on commit 44803b8

Please sign in to comment.