Skip to content
This repository was archived by the owner on Jul 1, 2021. It is now read-only.

Commit 12a0715

Browse files
committed
Check if channel is closed
1 parent 4094d54 commit 12a0715

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

conn_pool.go

+9-4
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,15 @@ func newPool(client *broadcast.Client, errHandler func(err error, conn *websocke
3030
}
3131

3232
go func() {
33-
for msg := range cp.client.Channel() {
34-
cp.mur.Lock()
35-
cp.router.Dispatch(msg)
36-
cp.mur.Unlock()
33+
for {
34+
select {
35+
case msg, ok := <-cp.client.Channel():
36+
if !ok {
37+
cp.mur.Lock()
38+
cp.router.Dispatch(msg)
39+
cp.mur.Unlock()
40+
}
41+
}
3742
}
3843
}()
3944

0 commit comments

Comments
 (0)