Skip to content

Commit

Permalink
Merge pull request #130 from nemith/nemith/channel_close_leak
Browse files Browse the repository at this point in the history
channel: don't leak go routine on close
  • Loading branch information
carlmontanari committed May 13, 2023
2 parents d8f1291 + 10882bf commit ec6e666
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions channel/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func NewChannel(
PromptPattern: getPromptPattern(),
ReturnChar: []byte(DefaultReturnChar),

done: make(chan bool),
done: make(chan struct{}),

Q: util.NewQueue(),
Errs: make(chan error),
Expand Down Expand Up @@ -105,7 +105,7 @@ type Channel struct {
PromptPattern *regexp.Regexp
ReturnChar []byte

done chan bool
done chan struct{}

Q *util.Queue
Errs chan error
Expand Down Expand Up @@ -172,9 +172,9 @@ func (c *Channel) Close() error {
ch := make(chan struct{})

go func() {
c.done <- true
c.done <- struct{}{}

ch <- struct{}{}
close(ch)
}()

select {
Expand Down

0 comments on commit ec6e666

Please sign in to comment.