Land #9744, Add synchronization around public module metadata cache methods
parent
04fcbbc70f
commit
a76a5ce83b
|
@ -24,17 +24,21 @@ class Cache
|
|||
# Refreshes cached module metadata as well as updating the store
|
||||
#
|
||||
def refresh_metadata_instance(module_instance)
|
||||
@mutex.synchronize {
|
||||
dlog "Refreshing #{module_instance.refname} of type: #{module_instance.type}"
|
||||
refresh_metadata_instance_internal(module_instance)
|
||||
update_store
|
||||
}
|
||||
end
|
||||
|
||||
#
|
||||
# Returns the module data cache, but first ensures all the metadata is loaded
|
||||
#
|
||||
def get_metadata
|
||||
@mutex.synchronize {
|
||||
wait_for_load
|
||||
@module_metadata_cache.values
|
||||
}
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -42,6 +46,7 @@ class Cache
|
|||
# if there are changes.
|
||||
#
|
||||
def refresh_metadata(module_sets)
|
||||
@mutex.synchronize {
|
||||
unchanged_module_references = get_unchanged_module_references
|
||||
has_changes = false
|
||||
module_sets.each do |mt|
|
||||
|
@ -75,8 +80,13 @@ class Cache
|
|||
end
|
||||
|
||||
update_store if has_changes
|
||||
}
|
||||
end
|
||||
|
||||
#######
|
||||
private
|
||||
#######
|
||||
|
||||
#
|
||||
# Returns a hash(type->set) which references modules that have not changed.
|
||||
#
|
||||
|
@ -102,10 +112,6 @@ class Cache
|
|||
return skip_reference_name_set_by_module_type
|
||||
end
|
||||
|
||||
#######
|
||||
private
|
||||
#######
|
||||
|
||||
def remove_from_cache(module_name)
|
||||
old_cache_size = @module_metadata_cache.size
|
||||
@module_metadata_cache.delete_if {|_, module_metadata|
|
||||
|
|
|
@ -23,6 +23,10 @@ module Msf::Modules::Metadata::Store
|
|||
load_metadata
|
||||
end
|
||||
|
||||
#######
|
||||
private
|
||||
#######
|
||||
|
||||
#
|
||||
# Update the module meta cache disk store
|
||||
#
|
||||
|
@ -39,10 +43,6 @@ module Msf::Modules::Metadata::Store
|
|||
end
|
||||
end
|
||||
|
||||
#######
|
||||
private
|
||||
#######
|
||||
|
||||
def load_metadata
|
||||
begin
|
||||
retries ||= 0
|
||||
|
|
Loading…
Reference in New Issue