]> git.cworth.org Git - sup/commitdiff
retry on imap ssl errors and better logging
authorwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Mon, 16 Apr 2007 22:59:57 +0000 (22:59 +0000)
committerwmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Mon, 16 Apr 2007 22:59:57 +0000 (22:59 +0000)
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@381 5c8cc53c-5e98-4d25-b20a-d8db53a31250

lib/sup/imap.rb

index d5ee887895392106d039ada8623ce51ec417c6bb..f79befba0d44160b5c6da2a7858edb30393dadc8 100644 (file)
@@ -34,7 +34,7 @@ class IMAP < Source
   SCAN_INTERVAL = 60 # seconds
 
   ## upon these errors we'll try to rereconnect a few times
-  RECOVERABLE_ERRORS = [ Errno::EPIPE, Errno::ETIMEDOUT ]
+  RECOVERABLE_ERRORS = [ Errno::EPIPE, Errno::ETIMEDOUT, OpenSSL::SSL::SSLError ]
 
   attr_accessor :username, :password
 
@@ -233,15 +233,17 @@ private
       begin
         unsafe_connect unless @imap
         yield
-      rescue *RECOVERABLE_ERRORS
+      rescue *RECOVERABLE_ERRORS => e
         if (retries += 1) <= 3
           @imap = nil
+          Redwood::log "got #{e.class.name}: #{e.message.inspect}"
+          sleep 2
           retry
         end
         raise
       end
     rescue SocketError, Net::IMAP::Error, SystemCallError, IOError, OpenSSL::SSL::SSLError => e
-      raise FatalSourceError, "While communicating with IMAP server (type #{e.class.name}): #{e.message}"
+      raise FatalSourceError, "While communicating with IMAP server (type #{e.class.name}): #{e.message.inspect}"
     end
   end