summaryrefslogtreecommitdiff
path: root/indra/llmessage/llares.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmessage/llares.cpp')
-rwxr-xr-x[-rw-r--r--]indra/llmessage/llares.cpp128
1 files changed, 74 insertions, 54 deletions
diff --git a/indra/llmessage/llares.cpp b/indra/llmessage/llares.cpp
index 00e77d20e9..9f90ae1544 100644..100755
--- a/indra/llmessage/llares.cpp
+++ b/indra/llmessage/llares.cpp
@@ -4,31 +4,25 @@
* @date 2007-08-15
* @brief Wrapper for asynchronous DNS lookups.
*
- * $LicenseInfo:firstyear=2007&license=viewergpl$
- *
- * Copyright (c) 2007-2009, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2007&license=viewerlgpl$
* Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * Copyright (C) 2010, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
*
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -61,13 +55,13 @@ LLAres::HostResponder::~HostResponder()
void LLAres::HostResponder::hostResult(const hostent *ent)
{
- llinfos << "LLAres::HostResponder::hostResult not implemented" << llendl;
+ LL_INFOS() << "LLAres::HostResponder::hostResult not implemented" << LL_ENDL;
}
void LLAres::HostResponder::hostError(int code)
{
- llinfos << "LLAres::HostResponder::hostError " << code << ": "
- << LLAres::strerror(code) << llendl;
+ LL_INFOS() << "LLAres::HostResponder::hostError " << code << ": "
+ << LLAres::strerror(code) << LL_ENDL;
}
LLAres::NameInfoResponder::~NameInfoResponder()
@@ -77,14 +71,14 @@ LLAres::NameInfoResponder::~NameInfoResponder()
void LLAres::NameInfoResponder::nameInfoResult(const char *node,
const char *service)
{
- llinfos << "LLAres::NameInfoResponder::nameInfoResult not implemented"
- << llendl;
+ LL_INFOS() << "LLAres::NameInfoResponder::nameInfoResult not implemented"
+ << LL_ENDL;
}
void LLAres::NameInfoResponder::nameInfoError(int code)
{
- llinfos << "LLAres::NameInfoResponder::nameInfoError " << code << ": "
- << LLAres::strerror(code) << llendl;
+ LL_INFOS() << "LLAres::NameInfoResponder::nameInfoError " << code << ": "
+ << LLAres::strerror(code) << LL_ENDL;
}
LLAres::QueryResponder::~QueryResponder()
@@ -93,33 +87,36 @@ LLAres::QueryResponder::~QueryResponder()
void LLAres::QueryResponder::queryResult(const char *buf, size_t len)
{
- llinfos << "LLAres::QueryResponder::queryResult not implemented"
- << llendl;
+ LL_INFOS() << "LLAres::QueryResponder::queryResult not implemented"
+ << LL_ENDL;
}
void LLAres::QueryResponder::queryError(int code)
{
- llinfos << "LLAres::QueryResponder::queryError " << code << ": "
- << LLAres::strerror(code) << llendl;
+ LL_INFOS() << "LLAres::QueryResponder::queryError " << code << ": "
+ << LLAres::strerror(code) << LL_ENDL;
}
LLAres::LLAres() :
chan_(NULL),
- mInitSuccess(false),
- mListener(new LLAresListener(this))
+ mInitSuccess(false)
{
- if (ares_init(&chan_) != ARES_SUCCESS)
+ if (ares_library_init( ARES_LIB_INIT_ALL ) != ARES_SUCCESS ||
+ ares_init(&chan_) != ARES_SUCCESS)
{
- llwarns << "Could not succesfully initialize ares!" << llendl;
+ LL_WARNS() << "Could not succesfully initialize ares!" << LL_ENDL;
return;
}
+ mListener = boost::shared_ptr< LLAresListener >(new LLAresListener(this));
+
mInitSuccess = true;
}
LLAres::~LLAres()
{
ares_destroy(chan_);
+ ares_library_cleanup();
}
void LLAres::cancel()
@@ -165,12 +162,26 @@ void LLAres::getSrvRecords(const std::string &name, SrvResponder *resp)
}
void LLAres::rewriteURI(const std::string &uri, UriRewriteResponder *resp)
-{
- llinfos << "Rewriting " << uri << llendl;
+{
+ if (resp && uri.size())
+ {
+ LLURI* pURI = new LLURI(uri);
+
+ resp->mUri = *pURI;
+
+ delete pURI;
+
+ if (!resp->mUri.scheme().size() || !resp->mUri.hostName().size())
+ {
+ return;
+ }
+
+ //LL_INFOS() << "LLAres::rewriteURI (" << uri << ") search: '" << "_" + resp->mUri.scheme() + "._tcp." + resp->mUri.hostName() << "'" << LL_ENDL;
+
+ search("_" + resp->mUri.scheme() + "._tcp." + resp->mUri.hostName(), RES_SRV, resp);
- resp->mUri = LLURI(uri);
- search("_" + resp->mUri.scheme() + "._tcp." + resp->mUri.hostName(),
- RES_SRV, resp);
+
+ }
}
LLQueryResponder::LLQueryResponder()
@@ -240,8 +251,8 @@ int LLQueryResponder::parseRR(const char *buf, size_t len, const char *&pos,
r = new LLSrvRecord(rrname, rrttl);
break;
default:
- llinfos << "LLQueryResponder::parseRR got unknown RR type " << rrtype
- << llendl;
+ LL_INFOS() << "LLQueryResponder::parseRR got unknown RR type " << rrtype
+ << LL_ENDL;
return ARES_EBADRESP;
}
@@ -322,7 +333,7 @@ void LLQueryResponder::queryResult(const char *buf, size_t len)
mType = (LLResType) t;
break;
default:
- llinfos << "Cannot grok query type " << t << llendl;
+ LL_INFOS() << "Cannot grok query type " << t << LL_ENDL;
ret = ARES_EBADQUERY;
goto bail;
}
@@ -362,7 +373,7 @@ bail:
void LLQueryResponder::querySuccess()
{
- llinfos << "LLQueryResponder::queryResult not implemented" << llendl;
+ LL_INFOS() << "LLQueryResponder::queryResult not implemented" << LL_ENDL;
}
void LLAres::SrvResponder::querySuccess()
@@ -382,23 +393,23 @@ void LLAres::SrvResponder::queryError(int code)
void LLAres::SrvResponder::srvResult(const dns_rrs_t &ents)
{
- llinfos << "LLAres::SrvResponder::srvResult not implemented" << llendl;
+ LL_INFOS() << "LLAres::SrvResponder::srvResult not implemented" << LL_ENDL;
for (size_t i = 0; i < ents.size(); i++)
{
const LLSrvRecord *s = (const LLSrvRecord *) ents[i].get();
- llinfos << "[" << i << "] " << s->host() << ":" << s->port()
+ LL_INFOS() << "[" << i << "] " << s->host() << ":" << s->port()
<< " priority " << s->priority()
<< " weight " << s->weight()
- << llendl;
+ << LL_ENDL;
}
}
void LLAres::SrvResponder::srvError(int code)
{
- llinfos << "LLAres::SrvResponder::srvError " << code << ": "
- << LLAres::strerror(code) << llendl;
+ LL_INFOS() << "LLAres::SrvResponder::srvError " << code << ": "
+ << LLAres::strerror(code) << LL_ENDL;
}
static void nameinfo_callback_1_5(void *arg, int status, int timeouts,
@@ -473,7 +484,7 @@ bool LLAres::process(U64 timeout)
ll_init_apr();
}
- int socks[ARES_GETSOCK_MAXNUM];
+ ares_socket_t socks[ARES_GETSOCK_MAXNUM];
apr_pollfd_t aprFds[ARES_GETSOCK_MAXNUM];
apr_int32_t nsds = 0;
int nactive = 0;
@@ -599,6 +610,15 @@ LLAres *ll_init_ares()
return gAres;
}
+void ll_cleanup_ares()
+{
+ if (gAres != NULL)
+ {
+ delete gAres;
+ gAres = NULL;
+ }
+}
+
LLDnsRecord::LLDnsRecord(LLResType type, const std::string &name,
unsigned ttl)
: LLRefCount(),
@@ -809,11 +829,11 @@ done:
void LLAres::UriRewriteResponder::rewriteResult(
const std::vector<std::string> &uris)
{
- llinfos << "LLAres::UriRewriteResponder::rewriteResult not implemented"
- << llendl;
+ LL_INFOS() << "LLAres::UriRewriteResponder::rewriteResult not implemented"
+ << LL_ENDL;
for (size_t i = 0; i < uris.size(); i++)
{
- llinfos << "[" << i << "] " << uris[i] << llendl;
+ LL_INFOS() << "[" << i << "] " << uris[i] << LL_ENDL;
}
}