Enhance race condition workaround in report_host

GSoC/Meterpreter_Web_Console
Matthew Kienow 2018-12-14 12:28:16 -05:00
parent c2af36f405
commit a683cedcce
No known key found for this signature in database
GPG Key ID: 40787F8B1EAC6E41
1 changed files with 3 additions and 3 deletions

View File

@ -258,9 +258,9 @@ module Msf::DBManager::Host
msf_import_timestamps(opts, host)
host.save!
end
rescue ActiveRecord::RecordNotUnique
# two concurrent report requests for a new host could result in a RecordNotUnique exception
# simply retry the report once more as an optimistic approach
rescue ActiveRecord::RecordNotUnique, ActiveRecord::RecordInvalid
# two concurrent report requests for a new host could result in a RecordNotUnique or
# RecordInvalid exception, simply retry the report once more as an optimistic approach
retry if (retry_attempts+=1) <= 1
raise
end