1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-07 13:11:28 +00:00

o [NSE] Added stop function to crawler so that scripts can properly shutdown

the crawler in case they want to end early. [Patrik]
This commit is contained in:
patrik
2011-12-11 10:59:35 +00:00
parent 3e8440f5f6
commit 74b53a6a14
2 changed files with 19 additions and 0 deletions

View File

@@ -561,6 +561,12 @@ Crawler = {
end
while(true) do
if ( self.quit ) then
table.insert(response_queue, {false, { err = false, msg = "Quit signalled by crawler" } })
break
end
-- in case the user set a max page count to retrieve check how many
-- pages we have retrieved so far
local count = self:getPageCount()
@@ -607,6 +613,7 @@ Crawler = {
end
condvar "signal"
end
condvar "signal"
end,
-- Loads the argument set on a script level
@@ -690,5 +697,14 @@ Crawler = {
end
end,
-- signals the crawler to stop
stop = function(self)
local condvar = nmap.condvar(self.response_queue)
self.quit = true
condvar "signal"
condvar "wait"
end
}