Handle a return() from a proc a bit more gracefully, add a test case
git-svn-id: file:///home/svn/framework3/trunk@8008 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
a414d5fc8f
commit
3f59ea2f95
|
@ -16,7 +16,6 @@ class TaskManager
|
|||
attr_accessor :proc
|
||||
attr_accessor :source
|
||||
attr_accessor :exception
|
||||
attr_accessor :retval
|
||||
|
||||
#
|
||||
# Create a new task
|
||||
|
@ -41,7 +40,7 @@ class TaskManager
|
|||
# Run the associated proc
|
||||
#
|
||||
def run(*args)
|
||||
self.retval = self.proc.call(*args) if self.proc
|
||||
self.proc.call(*args) if self.proc
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -158,6 +157,8 @@ class TaskManager
|
|||
else
|
||||
task.run(self, task)
|
||||
end
|
||||
rescue ::ThreadError
|
||||
# Ignore these (caused by a return inside of the proc)
|
||||
rescue ::Exception => e
|
||||
|
||||
if(e.class == ::Timeout::Error)
|
||||
|
|
|
@ -86,5 +86,17 @@ describe Msf::TaskManager do
|
|||
t.status.should == :dropped
|
||||
t.exception.class.should == ::NoMethodError
|
||||
end
|
||||
|
||||
it "should handle a bad proc return" do
|
||||
tm = Msf::TaskManager.new($msf)
|
||||
t = Msf::TaskManager::Task.new(Proc.new { return 12345 })
|
||||
|
||||
tm.start
|
||||
tm.queue_task(t)
|
||||
sleep(0.5)
|
||||
|
||||
t.status.should == :done
|
||||
t.exception.should == nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue