Skip to content

Commit

Permalink
ensure context is set before spawning goroutines using it (#2569)
Browse files Browse the repository at this point in the history
* ensure context is set before spawning goroutines using it

* ensure waiting gRPC calls aren't notified before context is set

Co-authored-by: Robert Bailey <[email protected]>
  • Loading branch information
Hades32 and roberthbailey authored May 11, 2022
1 parent 9d669d5 commit 015822a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/sdkserver/sdkserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ func (s *SDKServer) Run(ctx context.Context) error {
if !cache.WaitForCacheSync(ctx.Done(), s.gameServerSynced) {
return errors.New("failed to wait for caches to sync")
}

// need this for streaming gRPC commands
s.ctx = ctx
// we have the gameserver details now
s.gsWaitForSync.Done()

Expand Down Expand Up @@ -262,8 +265,6 @@ func (s *SDKServer) Run(ctx context.Context) error {
}()
defer s.server.Close() // nolint: errcheck

// need this for streaming gRPC commands
s.ctx = ctx
s.workerqueue.Run(ctx, 1)
return nil
}
Expand Down

0 comments on commit 015822a

Please sign in to comment.