Project

General

Profile

« Previous | Next » 

Revision b0ff68e0

Added by Marc Dequènes over 10 years ago

[fix] properly workaround exiting IMAP IDLE mode when run from a signal handler in order to stop gracefully

View differences:

lib/cyborghood/imap.rb
require 'thread'
module Net
class IMAP
def idle?
not @idle_done_cond.nil?
end
end
end
module CyborgHood
class IMAP
def initialize(params, min_check_interval)
......
check_inbox(&message_handler)
end
end
rescue CyberError => e
# used instead of wakeup to get out of IDLE mode
# (see comment when raised)
raise unless e.category == "shutdown"
end
def check_mails(&message_handler)
......
def stop_mail_check
@stop_mail_check = true
# wakeup do not work when run from a signal handler :-/
raise CyberError.new(:unrecoverable, "shutdown", "") if @imap.idle?
end
def check_inbox(&message_handler)

Also available in: Unified diff