Fix data race in tScreen shutdown

Setting t.quit to nil while the mainLoop is running causes a
race condition when the Fini() method is called. This change
instead uses a select expression to avoid the nil check and set.
This commit is contained in:
Tyler Sommer 2018-03-18 01:44:55 -06:00 committed by Garrett D'Amore
parent 23de111f3c
commit aa381bce1b
1 changed files with 5 additions and 2 deletions

View File

@ -398,9 +398,12 @@ func (t *tScreen) Fini() {
t.clear = false
t.fini = true
if t.quit != nil {
select {
case <-t.quit:
// do nothing, already closed
default:
close(t.quit)
t.quit = nil
}
t.termioFini()