Fix DNS resolution when cache is invalid.
Fix StreamPeerTCP.connect_to_host return value.
This commit is contained in:
parent
6671096dd7
commit
97757cd1d1
2 changed files with 3 additions and 4 deletions
|
@ -117,7 +117,7 @@ IP_Address IP::resolve_hostname(const String &p_hostname, IP::Type p_type) {
|
||||||
resolver->mutex->lock();
|
resolver->mutex->lock();
|
||||||
|
|
||||||
String key = _IP_ResolverPrivate::get_cache_key(p_hostname, p_type);
|
String key = _IP_ResolverPrivate::get_cache_key(p_hostname, p_type);
|
||||||
if (resolver->cache.has(key)) {
|
if (resolver->cache.has(key) && resolver->cache[key].is_valid()) {
|
||||||
IP_Address res = resolver->cache[key];
|
IP_Address res = resolver->cache[key];
|
||||||
resolver->mutex->unlock();
|
resolver->mutex->unlock();
|
||||||
return res;
|
return res;
|
||||||
|
@ -144,7 +144,7 @@ IP::ResolverID IP::resolve_hostname_queue_item(const String &p_hostname, IP::Typ
|
||||||
String key = _IP_ResolverPrivate::get_cache_key(p_hostname, p_type);
|
String key = _IP_ResolverPrivate::get_cache_key(p_hostname, p_type);
|
||||||
resolver->queue[id].hostname = p_hostname;
|
resolver->queue[id].hostname = p_hostname;
|
||||||
resolver->queue[id].type = p_type;
|
resolver->queue[id].type = p_type;
|
||||||
if (resolver->cache.has(key)) {
|
if (resolver->cache.has(key) && resolver->cache[key].is_valid()) {
|
||||||
resolver->queue[id].response = resolver->cache[key];
|
resolver->queue[id].response = resolver->cache[key];
|
||||||
resolver->queue[id].status = IP::RESOLVER_STATUS_DONE;
|
resolver->queue[id].status = IP::RESOLVER_STATUS_DONE;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -43,8 +43,7 @@ Error StreamPeerTCP::_connect(const String &p_address, int p_port) {
|
||||||
return ERR_CANT_RESOLVE;
|
return ERR_CANT_RESOLVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
connect_to_host(ip, p_port);
|
return connect_to_host(ip, p_port);
|
||||||
return OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void StreamPeerTCP::_bind_methods() {
|
void StreamPeerTCP::_bind_methods() {
|
||||||
|
|
Loading…
Reference in a new issue