diff options
-rwxr-xr-x[-rw-r--r--] | indra/newview/llmeshrepository.cpp | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/indra/newview/llmeshrepository.cpp b/indra/newview/llmeshrepository.cpp index 94ed2697c5..b26f2dd0de 100644..100755 --- a/indra/newview/llmeshrepository.cpp +++ b/indra/newview/llmeshrepository.cpp @@ -105,36 +105,42 @@ U32 get_volume_memory_size(const LLVolume* volume) std::string scrub_host_name(std::string http_url) { //curl loves to abuse the DNS cache, so scrub host names out of urls where trivial to prevent DNS timeouts + + if (http_url.empty()) + { + return http_url; + } + // Not safe to scrub amazon paths + if (http_url.find("s3.amazonaws.com") != std::string::npos) + { + return http_url; + } + std::string::size_type begin_host = http_url.find("://")+3; + std::string host_string = http_url.substr(begin_host); - if (!http_url.empty()) + std::string::size_type end_host = host_string.find(":"); + if (end_host == std::string::npos) { - std::string::size_type begin_host = http_url.find("://")+3; - std::string host_string = http_url.substr(begin_host); - - std::string::size_type end_host = host_string.find(":"); - if (end_host == std::string::npos) - { - end_host = host_string.find("/"); - } - - host_string = host_string.substr(0, end_host); + end_host = host_string.find("/"); + } + + host_string = host_string.substr(0, end_host); + + std::string::size_type idx = http_url.find(host_string); + + hostent* ent = gethostbyname(host_string.c_str()); + + if (ent && ent->h_length > 0) + { + U8* addr = (U8*) ent->h_addr_list[0]; - std::string::size_type idx = http_url.find(host_string); - - hostent* ent = gethostbyname(host_string.c_str()); - - if (ent && ent->h_length > 0) + std::string ip_string = llformat("%d.%d.%d.%d", addr[0], addr[1], addr[2], addr[3]); + if (!ip_string.empty() && !host_string.empty() && idx != std::string::npos) { - U8* addr = (U8*) ent->h_addr_list[0]; - - std::string ip_string = llformat("%d.%d.%d.%d", addr[0], addr[1], addr[2], addr[3]); - if (!ip_string.empty() && !host_string.empty() && idx != std::string::npos) - { - http_url.replace(idx, host_string.length(), ip_string); - } + http_url.replace(idx, host_string.length(), ip_string); } } - + return http_url; } |