diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-01-28 14:51:21 +0100 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-01-28 15:03:35 +0100 |
commit | 78978a4654ad851b0fa18bcd3d165b9c173f0375 (patch) | |
tree | b9e865f08c9dee1487e048f3dd1dfe930b6e418f /lib | |
parent | 2a2144addbcb717b983dd18f993f276cc8bd4ef8 (diff) |
ircbot: the reconnect must be protected
The reconnect() call in the main loop must be protected in the
begin/rescue blocks. Most of the rescue blocks can be fall-through,
because the begin/end is wrapped in a loop. The only exception is the
ServerError block that issues a retry lest too_fast is reset to false
even when it should be true.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rbot/ircbot.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index 0a18f04c..b47c235b 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -905,8 +905,9 @@ class Bot while true too_fast = false begin - quit if $interrupted > 0 quit_msg = nil + reconnect(quit_msg, too_fast) + quit if $interrupted > 0 while @socket.connected? quit if $interrupted > 0 @@ -936,6 +937,7 @@ class Bot # received an ERROR from the server quit_msg = "server ERROR: " + e.message too_fast = e.message.index("reconnect too fast") + retry rescue BDB::Fatal => e fatal "fatal bdb error: #{e.pretty_inspect}" DBTree.stats @@ -951,7 +953,6 @@ class Bot log_session_end exit 2 end - reconnect(quit_msg, too_fast) end end |