diff options
author | Wim <wim@42.be> | 2017-09-25 21:12:23 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2017-09-25 21:12:23 +0200 |
commit | a61e2db7cbdbda8292b8b50212072994512bccb3 (patch) | |
tree | 96ed7550245b2eccbba43c60808c8eb34135af71 /vendor | |
parent | 7aabe12acfb054561b85c95f34169d734a28b1eb (diff) | |
download | matterbridge-msglm-a61e2db7cbdbda8292b8b50212072994512bccb3.tar.gz matterbridge-msglm-a61e2db7cbdbda8292b8b50212072994512bccb3.tar.bz2 matterbridge-msglm-a61e2db7cbdbda8292b8b50212072994512bccb3.zip |
Backoff for 60 seconds when reconnecting too fast
Diffstat (limited to 'vendor')
-rw-r--r-- | vendor/github.com/42wim/go-ircevent/irc.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/vendor/github.com/42wim/go-ircevent/irc.go b/vendor/github.com/42wim/go-ircevent/irc.go index bcfe9ac2..ea9c1f05 100644 --- a/vendor/github.com/42wim/go-ircevent/irc.go +++ b/vendor/github.com/42wim/go-ircevent/irc.go @@ -227,12 +227,17 @@ func (irc *Connection) isQuitting() bool { // Main loop to control the connection. func (irc *Connection) Loop() { errChan := irc.ErrorChan() + connTime := time.Now() for !irc.isQuitting() { err := <-errChan close(irc.end) irc.Wait() for !irc.isQuitting() { irc.Log.Printf("Error, disconnected: %s\n", err) + if time.Now().Sub(connTime) < time.Second*5 { + irc.Log.Println("Rreconnecting too fast, sleeping 60 seconds") + time.Sleep(60 * time.Second) + } if err = irc.Reconnect(); err != nil { irc.Log.Printf("Error while reconnecting: %s\n", err) time.Sleep(60 * time.Second) @@ -241,6 +246,7 @@ func (irc *Connection) Loop() { break } } + connTime = time.Now() } } |