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

Some cleanup code is not triggered when using LobbyConnection.abort #707

Closed
Askaholic opened this issue Jan 27, 2021 · 0 comments · Fixed by #708
Closed

Some cleanup code is not triggered when using LobbyConnection.abort #707

Askaholic opened this issue Jan 27, 2021 · 0 comments · Fixed by #708
Assignees
Labels

Comments

@Askaholic
Copy link
Collaborator

We had some reports of a bug during TMM where a player who was trying to queue by themselves would get the "Only the party owner may enter the party into a queue" error message. It turns out this can be caused by an old party object not getting cleaned up, do to an aborted connection.

The problem is that there is no standard way for a service to handle cleanup for a closed connection. Each service has its own differently named cleanup function which is called by LobbyConnection.on_connection_lost, but only if LobbyConnection.player exists. However LobbyConnection.abort sets this field to None here:

if self.player:
self._logger.warning(
"Client %s dropped. %s", self.player.login, logspam
)
self.player_service.remove_player(self.player)
self.player = None

since on_connection_lost is called after the call to abort, this code never executes:
if self.player:
self._logger.debug(
"Lost lobby connection removing player %s", self.player.id
)
await self.ladder_service.on_connection_lost(self.player)
self.player_service.remove_player(self.player)
await self.party_service.on_player_disconnected(self.player)

I think we should add a standard on_connection_lost method to the Service base class and call it for all services from either Server or ServerContext when a disconnect happens.

@Askaholic Askaholic added the bug label Jan 27, 2021
@Askaholic Askaholic self-assigned this Jan 27, 2021
Askaholic added a commit that referenced this issue Feb 3, 2021
* Move on_connection_lost to Service base class

This enforces consistency accross all disconnect handlers and allows the
ServerContext to ensure that every disconnect handler is called.

* Add integration test

* Use eq for player comparision

* Add typing to limit
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 a pull request may close this issue.

1 participant