fix racism condition / deadlock
This commit is contained in:
@ -111,9 +111,18 @@ func HandleServerCommunication(conn net.Conn, playerID int32, player *types.Play
|
||||
for {
|
||||
select {
|
||||
case <-quitChan:
|
||||
<-done // Wait for action goroutine to finish
|
||||
close(done)
|
||||
time.Sleep(100 * time.Millisecond) // Give time for disconnect message to be sent
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
<-done
|
||||
close(player.QuitDone)
|
||||
}()
|
||||
|
||||
select {
|
||||
case <-done:
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
case <-time.After(1 * time.Second):
|
||||
log.Println("Shutdown timed out")
|
||||
}
|
||||
return
|
||||
default:
|
||||
// Read message length (4 bytes)
|
||||
|
Reference in New Issue
Block a user