Skip to content

Commit

Permalink
Fix proxy listener not being closed when the server is stopped
Browse files Browse the repository at this point in the history
  • Loading branch information
demdxx committed Sep 12, 2024
1 parent 38985ad commit d1ef2e7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions gochan/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,13 @@ func (p *Proxy) write(ctx context.Context, msg any) error {
// Listen starts processing queue
func (p *Proxy) Listen(ctx context.Context) error {
for msg := range p.pool {
if err := p.ProcessMessage(msg); err != nil {
return err
select {
case <-ctx.Done():
return ctx.Err()
default:
if err := p.ProcessMessage(msg); err != nil {
return err
}
}
}
return nil
Expand Down

0 comments on commit d1ef2e7

Please sign in to comment.