1
0
Fork 0

(svn r22695) -Fix [FS#4697]: mark addresses that could not be resolved as 'do not resolve anymore' as well, instead of trying to resolve them each and every time the address is accessed

release/1.2
rubidium 2011-07-30 10:28:52 +00:00
parent ba7611ed13
commit 289133be14
3 changed files with 10 additions and 5 deletions

View File

@ -132,6 +132,7 @@ const sockaddr_storage *NetworkAddress::GetAddress()
* that means "don't care whether it is SOCK_STREAM or SOCK_DGRAM". * that means "don't care whether it is SOCK_STREAM or SOCK_DGRAM".
*/ */
this->Resolve(this->address.ss_family, SOCK_STREAM, AI_ADDRCONFIG, NULL, ResolveLoopProc); this->Resolve(this->address.ss_family, SOCK_STREAM, AI_ADDRCONFIG, NULL, ResolveLoopProc);
this->resolved = true;
} }
return &this->address; return &this->address;
} }

View File

@ -33,6 +33,7 @@ private:
char hostname[NETWORK_HOSTNAME_LENGTH]; ///< The hostname char hostname[NETWORK_HOSTNAME_LENGTH]; ///< The hostname
int address_length; ///< The length of the resolved address int address_length; ///< The length of the resolved address
sockaddr_storage address; ///< The resolved address sockaddr_storage address; ///< The resolved address
bool resolved; ///< Whether the address has been (tried to be) resolved
/** /**
* Helper function to resolve something to a socket. * Helper function to resolve something to a socket.
@ -50,7 +51,8 @@ public:
*/ */
NetworkAddress(struct sockaddr_storage &address, int address_length) : NetworkAddress(struct sockaddr_storage &address, int address_length) :
address_length(address_length), address_length(address_length),
address(address) address(address),
resolved(address_length != 0)
{ {
*this->hostname = '\0'; *this->hostname = '\0';
} }
@ -61,7 +63,8 @@ public:
* @param address_length The length of the address. * @param address_length The length of the address.
*/ */
NetworkAddress(sockaddr *address, int address_length) : NetworkAddress(sockaddr *address, int address_length) :
address_length(address_length) address_length(address_length),
resolved(address_length != 0)
{ {
*this->hostname = '\0'; *this->hostname = '\0';
memset(&this->address, 0, sizeof(this->address)); memset(&this->address, 0, sizeof(this->address));
@ -75,7 +78,8 @@ public:
* @param family the address family * @param family the address family
*/ */
NetworkAddress(const char *hostname = "", uint16 port = 0, int family = AF_UNSPEC) : NetworkAddress(const char *hostname = "", uint16 port = 0, int family = AF_UNSPEC) :
address_length(0) address_length(0),
resolved(false)
{ {
/* Also handle IPv6 bracket enclosed hostnames */ /* Also handle IPv6 bracket enclosed hostnames */
if (StrEmpty(hostname)) hostname = ""; if (StrEmpty(hostname)) hostname = "";
@ -123,7 +127,7 @@ public:
*/ */
bool IsResolved() const bool IsResolved() const
{ {
return this->address_length != 0; return this->resolved;
} }
bool IsFamily(int family); bool IsFamily(int family);

View File

@ -491,9 +491,9 @@ static void NetworkUDPQueryServerThread(void *pntr)
/* Clear item in gamelist */ /* Clear item in gamelist */
NetworkGameList *item = CallocT<NetworkGameList>(1); NetworkGameList *item = CallocT<NetworkGameList>(1);
item->address = *info;
info->GetAddressAsString(item->info.server_name, lastof(item->info.server_name)); info->GetAddressAsString(item->info.server_name, lastof(item->info.server_name));
strecpy(item->info.hostname, info->GetHostname(), lastof(item->info.hostname)); strecpy(item->info.hostname, info->GetHostname(), lastof(item->info.hostname));
item->address = *info;
item->manually = info->manually; item->manually = info->manually;
NetworkGameListAddItemDelayed(item); NetworkGameListAddItemDelayed(item);