mirror of
https://github.com/urbanadventurer/WhatWeb
synced 2026-06-21 14:12:19 +00:00
Merge branch 'fix-plugin-locking'
This commit is contained in:
+5
-2
@@ -22,13 +22,16 @@ class Plugin
|
||||
def_field :examples
|
||||
#, :category
|
||||
@registered_plugins = {}
|
||||
attr :mutex
|
||||
|
||||
class << self
|
||||
attr_reader :registered_plugins
|
||||
private :new
|
||||
attr_reader :locked
|
||||
attr_reader :plugin_name
|
||||
@locked=false
|
||||
end
|
||||
|
||||
def initialize
|
||||
@mutex = Mutex.new
|
||||
end
|
||||
|
||||
def self.define(name, &block)
|
||||
|
||||
@@ -384,34 +384,24 @@ end
|
||||
### core
|
||||
|
||||
def run_plugins(target)
|
||||
results=[]
|
||||
$plugins_to_use.each do |name,plugin|
|
||||
begin
|
||||
while plugin.locked?
|
||||
#sleep 0.1
|
||||
puts "Waiting for plugin:#{name} to unlock" if $verbose > 2
|
||||
Thread.pass
|
||||
end
|
||||
plugin.lock
|
||||
|
||||
plugin.init(target)
|
||||
|
||||
# eXecute the plugin
|
||||
#start_time = Time.now
|
||||
result=plugin.x
|
||||
#end_time = Time.now
|
||||
#$PLUGIN_TIMES[name] += end_time - start_time
|
||||
|
||||
plugin.unlock
|
||||
|
||||
rescue Exception => err
|
||||
error("ERROR: Plugin #{name} failed for #{target.to_s}. #{err}")
|
||||
plugin.unlock
|
||||
raise if $WWDEBUG == true
|
||||
end
|
||||
results << [name, result] unless result.nil? or result.empty?
|
||||
end
|
||||
results
|
||||
results = []
|
||||
$plugins_to_use.each do |name, plugin|
|
||||
result = plugin.mutex.synchronize do
|
||||
begin
|
||||
plugin.init(target)
|
||||
# eXecute the plugin
|
||||
#start_time = Time.now
|
||||
plugin.x
|
||||
#end_time = Time.now
|
||||
#$PLUGIN_TIMES[name] += end_time - start_time
|
||||
rescue Exception => err
|
||||
error("ERROR: Plugin #{name} failed for #{target}. #{err}")
|
||||
raise if $WWDEBUG == true
|
||||
end
|
||||
end
|
||||
results << [name, result] unless result.nil? or result.empty?
|
||||
end
|
||||
results
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user