Cancel reconnect retries during shutdown
This commit is contained in:
committed by
Brandon McGinty
parent
e68546eec5
commit
1d6ab79ed0
@@ -14,6 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func (b *Barnard) start() {
|
||||
b.reconnectStop = make(chan struct{})
|
||||
b.Config.Attach(gumbleutil.AutoBitrate)
|
||||
b.Config.Attach(b)
|
||||
b.Config.Address = b.Address
|
||||
@@ -218,12 +219,15 @@ func (b *Barnard) OnDisconnect(e *gumble.DisconnectEvent) {
|
||||
}
|
||||
|
||||
func (b *Barnard) reconnectGoroutine() {
|
||||
for {
|
||||
res := b.connect(true)
|
||||
if res == true {
|
||||
break
|
||||
for !b.reconnectCanceled() {
|
||||
if b.connect(true) {
|
||||
return
|
||||
}
|
||||
select {
|
||||
case <-b.reconnectStop:
|
||||
return
|
||||
case <-time.After(15 * time.Second):
|
||||
}
|
||||
time.Sleep(15 * time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user