Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix race in creating calls #2663

Closed
wants to merge 1 commit into from
Closed

Conversation

dbkr
Copy link
Member

@dbkr dbkr commented Sep 12, 2022

Second attempt, just put a mutex around the method that processes member state events. The previous change meant that uninitialised calls were sitting in the map which is not a thing this code is prepared to handle and was causing test failures.

Also more logging.

Supersedes #2662

Checklist

  • Tests written for new code (and old code if feasible)
  • Linter and other CI checks pass
  • Sign-off given on the changes (see CONTRIBUTING.md)

Here's what your changelog entry will look like:

🐛 Bug Fixes

  • Fix race in creating calls (#2663).

Second attempt, just put a mutex around the method that processes
member state events.

Also more logging.

Supersedes #2662
@dbkr dbkr added the T-Defect label Sep 12, 2022
@dbkr dbkr requested a review from a team as a code owner September 12, 2022 16:41
Copy link
Contributor

@SimonBrandner SimonBrandner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, LGTM

@@ -185,6 +185,9 @@ export class GroupCall extends TypedEventEmitter<
private resendMemberStateTimer: ReturnType<typeof setInterval> | null = null;
private initWithAudioMuted = false;
private initWithVideoMuted = false;
// We use this as a set of mutexes, effectively, to make sure we only enter the function
// to process a member state event once at any one time for each member
private processingMemberStateEvent = new Map<string, boolean>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a map? Wouldn't a Set work?

Comment on lines +773 to +777
try {
return this.processMemberStateEventInternal(event);
} finally {
this.processingMemberStateEvent.delete(event.getStateKey());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the benefit of try/finally here?

@SimonBrandner
Copy link
Contributor

Also, what if the event changes while we're processing it?

@dbkr
Copy link
Member Author

dbkr commented Sep 12, 2022

Hmm, yes, you're right. We need to handle the newer ones somehow.

@dbkr
Copy link
Member Author

dbkr commented Sep 13, 2022

Going back to #2662 again

@dbkr dbkr closed this Sep 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants