From e71da5f7e95faf8e1a7b6e50fb32ebe37da5c1f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Wed, 11 Dec 2019 14:59:40 +0100 Subject: [PATCH] Protocols.HTTP: Use Protocols.DNS.async_host_to_ip(). Most Protocols.HTTP.Query objects had their own Protocols.DNS.async_client (and related Stdio.UDP). Fixes [PIKE-195]. --- .../Protocols.pmod/HTTP.pmod/Query.pike | 44 +------------------ 1 file changed, 1 insertion(+), 43 deletions(-) diff --git a/lib/modules/Protocols.pmod/HTTP.pmod/Query.pike b/lib/modules/Protocols.pmod/HTTP.pmod/Query.pike index 176a45da32..3662919591 100644 --- a/lib/modules/Protocols.pmod/HTTP.pmod/Query.pike +++ b/lib/modules/Protocols.pmod/HTTP.pmod/Query.pike @@ -490,32 +490,10 @@ string headers_encode(mapping(string:array(string)|string) h) //! mapping hostname_cache=([]); -protected Protocols.DNS.async_client async_dns; -protected int last_async_dns; -protected mixed async_id; - #ifndef PROTOCOLS_HTTP_DNS_OBJECT_TIMEOUT #define PROTOCOLS_HTTP_DNS_OBJECT_TIMEOUT 60 #endif -// Check if it's time to clean up the async dns object. -protected void clean_async_dns() -{ - int time_left = last_async_dns + PROTOCOLS_HTTP_DNS_OBJECT_TIMEOUT - time(1); - if (time_left >= 0) { - // Not yet. - async_id = call_out(clean_async_dns, time_left + 1); - return; - } - async_id = 0; - - if(async_dns) - async_dns->close(); - async_dns = 0; - - last_async_dns = 0; -} - void dns_lookup_callback(string name,string ip,function callback, mixed ...extra) { @@ -546,14 +524,7 @@ void dns_lookup_async(string hostname,function callback,mixed ...extra) return; } - if (!async_dns) { - async_dns = Protocols.DNS.async_client(); - } - async_dns->host_to_ip(hostname, dns_lookup_callback, callback, @extra); - last_async_dns = time(1); - if (!async_id) { - async_id = call_out(clean_async_dns, PROTOCOLS_HTTP_DNS_OBJECT_TIMEOUT+1); - } + Protocols.DNS.async_host_to_ip(hostname, dns_lookup_callback, callback, @extra); } string dns_lookup(string hostname) @@ -1211,15 +1182,6 @@ object datafile() protected void destroy() { - if (async_id) { - remove_call_out(async_id); - } - async_id = 0; - if(async_dns) { - async_dns->close(); - async_dns = 0; - } - catch(close_connection(1)); } @@ -1228,10 +1190,6 @@ protected void destroy() void close() { close_connection(); - if(async_dns) { - async_dns->close(); - async_dns = 0; - } } //! Fetch all data in background. -- GitLab