mirror of https://github.com/chzyer/readline.git
Fix a race condition in terminal.go
There is a race condition in terminal.go relating to wait groups. The wg.Add method should be called by the parent goroutine, not the child. https://golang.org/pkg/sync/#WaitGroup This was caught by gotsan.
This commit is contained in:
parent
2972be24d4
commit
fa0594f54b
|
@ -35,6 +35,7 @@ func NewTerminal(cfg *Config) (*Terminal, error) {
|
||||||
sizeChan: make(chan string, 1),
|
sizeChan: make(chan string, 1),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
t.wg.Add(1)
|
||||||
go t.ioloop()
|
go t.ioloop()
|
||||||
return t, nil
|
return t, nil
|
||||||
}
|
}
|
||||||
|
@ -116,7 +117,6 @@ func (t *Terminal) KickRead() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Terminal) ioloop() {
|
func (t *Terminal) ioloop() {
|
||||||
t.wg.Add(1)
|
|
||||||
defer func() {
|
defer func() {
|
||||||
t.wg.Done()
|
t.wg.Done()
|
||||||
close(t.outchan)
|
close(t.outchan)
|
||||||
|
|
Loading…
Reference in New Issue