1
mirror of https://github.com/rapid7/metasploit-framework synced 2024-11-05 14:57:30 +01:00

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-b9f4589650da
This commit is contained in:
HD Moore 2009-12-28 19:44:14 +00:00
parent a414d5fc8f
commit 3f59ea2f95
2 changed files with 15 additions and 2 deletions

View File

@ -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)

View File

@ -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