mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 02:48:28 +08:00
FIX: allow changing default DNS query timeout of 2s via GlobalSetting (#20383)
The current default timeout is hardcoded to 2 seconds which is proving too low for certain cases, and resulting in sporadic timeouts due to slow DNS queries.
This commit is contained in:

committed by
GitHub

parent
8c80d330fa
commit
509fee0f5a
@ -3,7 +3,8 @@
|
||||
class FinalDestination::Resolver
|
||||
@mutex = Mutex.new
|
||||
def self.lookup(addr, timeout: nil)
|
||||
timeout ||= 2
|
||||
timeout ||= default_dns_query_timeout
|
||||
|
||||
@mutex.synchronize do
|
||||
@result = nil
|
||||
|
||||
@ -36,6 +37,14 @@ class FinalDestination::Resolver
|
||||
|
||||
private
|
||||
|
||||
def self.default_dns_query_timeout
|
||||
if gs = GlobalSetting.dns_query_timeout_secs.presence
|
||||
Integer(gs)
|
||||
else
|
||||
2
|
||||
end
|
||||
end
|
||||
|
||||
def self.ensure_lookup_thread
|
||||
return if @thread&.alive?
|
||||
|
||||
|
Reference in New Issue
Block a user