commit 7e12b2ed17d37009eff42241206e5e2e869289dd
parent d8c553bd1a7864d42f06d6980f23d5f0882dcaf3
Author: wmorgan <wmorgan@5c8cc53c-5e98-4d25-b20a-d8db53a31250>
Date: Wed, 13 Jun 2007 00:39:33 +0000
yet more better intra-saving exception resilience
git-svn-id: svn://rubyforge.org/var/svn/sup/trunk@451 5c8cc53c-5e98-4d25-b20a-d8db53a31250
Diffstat:
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/bin/sup b/bin/sup
@@ -254,8 +254,8 @@ rescue Exception => e
$exception ||= e
ensure
unless $opts[:no_threads]
- PollManager.stop
- SuicideManager.stop
+ PollManager.stop if PollManager.instantiated?
+ SuicideManager.stop if PollManager.instantiated?
Index.stop_lock_update_thread
end
diff --git a/lib/sup.rb b/lib/sup.rb
@@ -104,7 +104,6 @@ module Redwood
end
def finish
- Redwood::PollManager.stop
Redwood::LabelManager.save if Redwood::LabelManager.instantiated?
Redwood::ContactManager.save if Redwood::ContactManager.instantiated?
Redwood::PersonManager.save if Redwood::PersonManager.instantiated?
diff --git a/lib/sup/util.rb b/lib/sup/util.rb
@@ -310,6 +310,13 @@ module Singleton
def deinstantiate!; @instance = nil; end
def method_missing meth, *a, &b
raise "no instance defined!" unless defined? @instance
+
+ ## if we've been deinstantiated, just drop all calls. this is
+ ## useful because threads that might be active during the
+ ## cleanup process (e.g. polling) would otherwise have to
+ ## special-case every call to a Singleton object
+ return nil if @instance.nil?
+
@instance.send meth, *a, &b
end
def i_am_the_instance o