Skip to content

Commit

Permalink
Ensure we stop clients when we cull them
Browse files Browse the repository at this point in the history
  • Loading branch information
Half-Shot committed Jan 14, 2021
1 parent 5803d52 commit f745f5b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/components/encryption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class EncryptedEventBroker {
// We should probably make these LRUs eventually
private eventsPendingAS: WeakEvent[] = [];

private syncingClients = new Set<any>();
private syncingClients = new Map<string,any>();

/**
* Called when the bridge gets an event through an appservice transaction.
Expand Down Expand Up @@ -301,11 +301,16 @@ export class EncryptedEventBroker {
resolveInvitesToProfiles: false,
filter,
});
this.syncingClients.add(matrixClient);
this.syncingClients.set(userId, matrixClient);
}

public shouldAvoidCull(intent: Intent) {
return this.syncingClients.has(intent.client);
const avoidCull = this.syncingClients.has(intent.client);
if (!avoidCull) {
// If we ARE culling the client then ensure they stop syncing too.
this.syncingClients.get(intent.userId)?.stopClient();
}
return avoidCull;
}

/**
Expand Down

0 comments on commit f745f5b

Please sign in to comment.