Avoid long viewer freezes when region doesn't have reverse DNS.

Some opensim servers might not have a reverse DNS, which causes
a stall of up to 5 seconds for each call. This means that
every time you up the parcel music stream (or any other media)
the viewer would freeze six times 5 seconds.. 30 seconds.

With this patch it only freeze once ;) (when you enter a region).
It already did that before (too), but after that opening the
parcel media doesn't freeze the viewer at all anymore.
This commit is contained in:
Aleric Inglewood
2013-09-23 01:41:11 +02:00
parent 12d3873aa7
commit e3939c3632
3 changed files with 41 additions and 17 deletions

View File

@@ -59,11 +59,12 @@ LLHost::LLHost(const std::string& ip_and_port)
mIP = ip_string_to_u32(ip_str.c_str());
mPort = atol(port_str.c_str());
}
mHostNotFound = 0;
}
std::string LLHost::getString() const
{
return llformat("%s:%u", u32_to_ip_string(mIP), mPort);
return llformat("%s:%hu", u32_to_ip_string(mIP), mPort);
}
@@ -87,16 +88,27 @@ std::string LLHost::getHostName() const
llwarns << "LLHost::getHostName() : Invalid IP address" << llendl;
return std::string();
}
if (mHostNotFound)
{
// We already checked this... avoid freezing the viewer 5 seconds again and again.
llwarns << "LLHost::getHostName() : Returning cached HOST_NOT_FOUND." << llendl;
return std::string();
}
he = gethostbyaddr((char *)&mIP, sizeof(mIP), AF_INET);
if (!he)
{
#if LL_WINDOWS
llwarns << "LLHost::getHostName() : Couldn't find host name for address " << mIP << ", Error: "
<< WSAGetLastError() << llendl;
int err = WSAGetLastError();
int err_host_not_found = WSAHOST_NOT_FOUND;
#else
llwarns << "LLHost::getHostName() : Couldn't find host name for address " << mIP << ", Error: "
<< h_errno << llendl;
int err = h_errno;
int err_host_not_found = HOST_NOT_FOUND;
#endif
llwarns << "LLHost::getHostName() : Couldn't find host name for address " << mIP << ", Error: " << err << llendl;
if (err == err_host_not_found)
{
mHostNotFound = 1;
}
return std::string();
}
else
@@ -125,6 +137,7 @@ BOOL LLHost::setHostByName(const std::string& hostname)
if (he)
{
mIP = *(U32 *)he->h_addr_list[0];
mHostNotFound = 0;
return TRUE;
}
else