Skip to content
Snippets Groups Projects
Commit e71da5f7 authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

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].
parent b4ffc568
No related branches found
No related tags found
No related merge requests found
...@@ -490,32 +490,10 @@ string headers_encode(mapping(string:array(string)|string) h) ...@@ -490,32 +490,10 @@ string headers_encode(mapping(string:array(string)|string) h)
//! //!
mapping hostname_cache=([]); 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 #ifndef PROTOCOLS_HTTP_DNS_OBJECT_TIMEOUT
#define PROTOCOLS_HTTP_DNS_OBJECT_TIMEOUT 60 #define PROTOCOLS_HTTP_DNS_OBJECT_TIMEOUT 60
#endif #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, void dns_lookup_callback(string name,string ip,function callback,
mixed ...extra) mixed ...extra)
{ {
...@@ -546,14 +524,7 @@ void dns_lookup_async(string hostname,function callback,mixed ...extra) ...@@ -546,14 +524,7 @@ void dns_lookup_async(string hostname,function callback,mixed ...extra)
return; return;
} }
if (!async_dns) { Protocols.DNS.async_host_to_ip(hostname, dns_lookup_callback, callback, @extra);
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);
}
} }
string dns_lookup(string hostname) string dns_lookup(string hostname)
...@@ -1211,15 +1182,6 @@ object datafile() ...@@ -1211,15 +1182,6 @@ object datafile()
protected void destroy() 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)); catch(close_connection(1));
} }
...@@ -1228,10 +1190,6 @@ protected void destroy() ...@@ -1228,10 +1190,6 @@ protected void destroy()
void close() void close()
{ {
close_connection(); close_connection();
if(async_dns) {
async_dns->close();
async_dns = 0;
}
} }
//! Fetch all data in background. //! Fetch all data in background.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment