Attempt to fix the orphan client issue.
This commit is contained in:
parent
7a9ec1a1d3
commit
04d4e0fc6a
10
main.go
10
main.go
|
@ -168,6 +168,7 @@ func broadcastFiber(name string) {
|
|||
e := ctx.clientsChanList.Front()
|
||||
for e != nil {
|
||||
ch := e.Value.(*ClientChannel)
|
||||
// Note: select in Golang is not ordered!
|
||||
select {
|
||||
case <-ch.Notify:
|
||||
// Closed client, remove this entry
|
||||
|
@ -175,11 +176,14 @@ func broadcastFiber(name string) {
|
|||
next := e.Next()
|
||||
ctx.clientsChanList.Remove(e)
|
||||
e = next
|
||||
case ch.Data <- chunk:
|
||||
e = e.Next()
|
||||
break
|
||||
default:
|
||||
e = e.Next()
|
||||
}
|
||||
select {
|
||||
case ch.Data <- chunk:
|
||||
default:
|
||||
}
|
||||
e = e.Next()
|
||||
}
|
||||
// Try to serve all new clients, but don't get locked up here :)
|
||||
if ctx.newClientsChanList.Len() > 0 && ctx.newChanLock.TryLock() {
|
||||
|
|
Loading…
Reference in New Issue