summaryrefslogtreecommitdiff
path: root/src/network/core/address.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-07-30 10:28:52 +0000
committerrubidium <rubidium@openttd.org>2011-07-30 10:28:52 +0000
commit289133be148788a19a965f807e7b824c4d26f872 (patch)
treefa0820207322815661878611fb98b8b6013475d5 /src/network/core/address.h
parentba7611ed131b0f99dae4ca974aa1cf9c6114b6f5 (diff)
downloadopenttd-289133be148788a19a965f807e7b824c4d26f872.tar.xz
(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
Diffstat (limited to 'src/network/core/address.h')
-rw-r--r--src/network/core/address.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/network/core/address.h b/src/network/core/address.h
index d2d43b4a9..9fd40eaee 100644
--- a/src/network/core/address.h
+++ b/src/network/core/address.h
@@ -33,6 +33,7 @@ private:
char hostname[NETWORK_HOSTNAME_LENGTH]; ///< The hostname
int address_length; ///< The length of 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.
@@ -50,7 +51,8 @@ public:
*/
NetworkAddress(struct sockaddr_storage &address, int address_length) :
address_length(address_length),
- address(address)
+ address(address),
+ resolved(address_length != 0)
{
*this->hostname = '\0';
}
@@ -61,7 +63,8 @@ public:
* @param address_length The length of the address.
*/
NetworkAddress(sockaddr *address, int address_length) :
- address_length(address_length)
+ address_length(address_length),
+ resolved(address_length != 0)
{
*this->hostname = '\0';
memset(&this->address, 0, sizeof(this->address));
@@ -75,7 +78,8 @@ public:
* @param family the address family
*/
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 */
if (StrEmpty(hostname)) hostname = "";
@@ -123,7 +127,7 @@ public:
*/
bool IsResolved() const
{
- return this->address_length != 0;
+ return this->resolved;
}
bool IsFamily(int family);