pacgo icon indicating copy to clipboard operation
pacgo copied to clipboard

Some race-condition may not get addressed,I am not sure

Open AlanYeg opened this issue 2 years ago • 2 comments

` var pillTimer *time.Timer var pillMx sync.Mutex

func processPill() { pillMx.Lock() updateGhosts(ghosts, GhostStatusBlue) if pillTimer != nil { pillTimer.Stop() } pillTimer = time.NewTimer(time.Second * cfg.PillDurationSecs) pillMx.Unlock() <-pillTimer.C /gorotine a gets here,next to execute is pillMx.Lock(),but goroutine b gets control(the lock is free now.)execute from the beginning of the funtion to this line,blocked by pillTimer channel.however gorotine a now get the lock,it continues ,in this case,will ghosts get normal?/ pillMx.Lock() pillTimer.Stop() updateGhosts(ghosts, GhostStatusNormal) pillMx.Unlock() }

AlanYeg avatar Mar 12 '22 12:03 AlanYeg

it's in step10 main.go.

AlanYeg avatar Mar 12 '22 12:03 AlanYeg

Hi Alan, please review issue #38. IMHO. this is where the concurrency issues start in step6. If issue #38 is fixed, we need to rework fully the waiting period for a dead player and the structure of the source. There must be a new game loop for every player created. This will probably affect the pill behavior too.

rpoe avatar Mar 12 '22 17:03 rpoe