Skip to content

Commit

Permalink
stop session garbage collector when lobby done
Browse files Browse the repository at this point in the history
  • Loading branch information
EnricoSchw committed Mar 11, 2024
1 parent 282f888 commit 489967f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions internal/lobby/lobby.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,16 @@ func newLobby(id uuid.UUID, entity *LobbyEntity) *lobby {
sessionGarbageCollector: sessionGarbageCollector,
}
go func() {
for id := range sessionGarbageCollector {
if ok := lobby.sessions.Delete(id); !ok {
slog.Warn("session could not delete", "session id", id)
for {
select {
case sessionId := <-sessionGarbageCollector:

if ok := lobby.sessions.Delete(sessionId); !ok {
slog.Warn("session could not delete", "session id", sessionId)
}
case <-lobby.ctx.Done():
slog.Debug("stop session garbage collector")
return
}
}
}()
Expand Down

0 comments on commit 489967f

Please sign in to comment.