Skip to content

Unsubscribe from 'token_received' events before re-subscribing #630

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

Merged
merged 2 commits into from
Mar 2, 2020

Conversation

l1b3r
Copy link
Contributor

@l1b3r l1b3r commented Sep 18, 2019

OAuthService::setupRefreshTimer is called multiple times from several places in the code, e.g. from the constructor of the service or when a storage is changed via OAuthService::setStorage.

The setupRefreshTimer is itself subscribing to OAuthService::events each time it's called, and the subscriptions get stacked creating at the very least a memory leak. In the worst case, this can also lead to undefined behavior and race conditions since the subscription handler of this.events... in setupRefreshTimer is calling setupExpirationTimers which in turn is also performing subscriptions.

This PR adds a resubscription procedure to setupRefreshTimer which will unsubscribe from OAuthService::events before subscribing to them again.

@manfredsteyer manfredsteyer merged commit d49021a into manfredsteyer:master Mar 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants