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 goroutine leak in game frontend #47

Merged
merged 2 commits into from
Jul 2, 2024
Merged

Conversation

govargo
Copy link
Collaborator

@govargo govargo commented Jun 28, 2024

When I wrote the code with following space-agon's codebase, I found that my code has leaked goroutine in the container process.

スクリーンショット 2024-06-28 20 37 58

I investigated and found that the following code in game frontend doesn't release the goroutine by e.g. break, return.

# current code
for {
  resp, err := stream.Recv()
  if err != nil {
    errs <- fmt.Errorf("error streaming assignment: %w", err)
    return
  }
  assignments <- resp.Assignment
}

This code leads to goroutine leak.
This PR fixes this problem.

I followed the example in open-match client example's code.
https://github.com/googleforgames/open-match/blob/main/examples/demo/components/clients/clients.go#L119-L126

Copy link
Collaborator

@kemurayama kemurayama left a comment

Choose a reason for hiding this comment

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

LGTM

@kemurayama kemurayama merged commit 30e8ca2 into googleforgames:main Jul 2, 2024
5 checks passed
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