]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
ircbot: the reconnect must be protected
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 28 Jan 2009 13:51:21 +0000 (14:51 +0100)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Wed, 28 Jan 2009 14:03:35 +0000 (15:03 +0100)
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.

lib/rbot/ircbot.rb

index 0a18f04c21f262e6aaf8b97d084e7727cb1d1116..b47c235b6b03ce3f50dbed12f0036b8fa4a0e712 100644 (file)
@@ -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