From 7f9a979b04fbacda7343b1bcbda1ce83bfb31402 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Tue, 20 Oct 2009 20:22:22 +0200 Subject: 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. --- lib/rbot/ircbot.rb | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'lib') 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 -- cgit v1.2.3