diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-10-20 20:22:22 +0200 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-10-21 18:59:21 +0200 |
commit | 7f9a979b04fbacda7343b1bcbda1ce83bfb31402 (patch) | |
tree | b93fa30593a943bb086aaff99916a645d4ca0d49 /lib | |
parent | 5829ccecaf24f2adb47f8f98a778ba9e3d3cc90b (diff) |
Loop until connected in reconnect()
Untrapped connect() failures would raise up to the mainloop, causing a
burst of reconnect attempts without delay. Fix by rescuing in
reconnect() and retrying after waiting.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rbot/ircbot.rb | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index 2f146c29..6f7bed7d 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -940,17 +940,22 @@ class Bot disconnect(message) end - if will_wait - log "\n\nDisconnected\n\n" + begin + if will_wait + log "\n\nDisconnected\n\n" - quit if $interrupted > 0 + quit if $interrupted > 0 - log "\n\nWaiting to reconnect\n\n" - sleep @config['server.reconnect_wait'] - sleep 10*@config['server.reconnect_wait'] if too_fast - end + log "\n\nWaiting to reconnect\n\n" + sleep @config['server.reconnect_wait'] + sleep 10*@config['server.reconnect_wait'] if too_fast + end - connect + connect + rescue Exception => e + will_wait = true + retry + end end # begin event handling loop |