summaryrefslogtreecommitdiff
path: root/indra/llmessage/llares.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmessage/llares.cpp')
-rw-r--r--indra/llmessage/llares.cpp91
1 files changed, 51 insertions, 40 deletions
diff --git a/indra/llmessage/llares.cpp b/indra/llmessage/llares.cpp
index d11f227c21..5a67035ed1 100644
--- a/indra/llmessage/llares.cpp
+++ b/indra/llmessage/llares.cpp
@@ -4,34 +4,30 @@
* @date 2007-08-15
* @brief Wrapper for asynchronous DNS lookups.
*
- * $LicenseInfo:firstyear=2007&license=viewergpl$
- *
- * Copyright (c) 2007, 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://secondlife.com/developers/opensource/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://secondlife.com/developers/opensource/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$
*/
#include "linden_common.h"
+#include "llares.h"
#include <ares_dns.h>
#include <ares_version.h>
@@ -41,9 +37,10 @@
#include "apr_poll.h"
#include "llapr.h"
-#include "llares.h"
+#include "llareslistener.h"
#if defined(LL_WINDOWS)
+#pragma warning (disable : 4355) // 'this' used in initializer list: yes, intentionally
# define ns_c_in 1
# define NS_HFIXEDSZ 12 /* #/bytes of fixed data in header */
# define NS_QFIXEDSZ 4 /* #/bytes of fixed data in query */
@@ -100,14 +97,25 @@ void LLAres::QueryResponder::queryError(int code)
<< LLAres::strerror(code) << llendl;
}
-LLAres::LLAres()
+LLAres::LLAres() :
+ chan_(NULL),
+ mInitSuccess(false),
+ mListener(new LLAresListener(this))
{
- ares_init(&chan_);
+ if (ares_library_init( ARES_LIB_INIT_ALL ) != ARES_SUCCESS ||
+ ares_init(&chan_) != ARES_SUCCESS)
+ {
+ llwarns << "Could not succesfully initialize ares!" << llendl;
+ return;
+ }
+
+ mInitSuccess = true;
}
LLAres::~LLAres()
{
ares_destroy(chan_);
+ ares_library_cleanup();
}
void LLAres::cancel()
@@ -163,7 +171,8 @@ void LLAres::rewriteURI(const std::string &uri, UriRewriteResponder *resp)
LLQueryResponder::LLQueryResponder()
: LLAres::QueryResponder(),
- mResult(ARES_ENODATA)
+ mResult(ARES_ENODATA),
+ mType(RES_INVALID)
{
}
@@ -460,11 +469,9 @@ 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;
- apr_status_t status;
- apr_pool_t *pool;
+ apr_int32_t nsds = 0;
int nactive = 0;
int bitmask;
@@ -472,10 +479,12 @@ bool LLAres::process(U64 timeout)
if (bitmask == 0)
{
- goto bail;
+ return nsds > 0;
}
- status = apr_pool_create(&pool, gAPRPoolp);
+ apr_status_t status;
+ LLAPRPool pool;
+ status = pool.getStatus() ;
ll_apr_assert_status(status);
for (int i = 0; i < ARES_GETSOCK_MAXNUM; i++)
@@ -493,16 +502,16 @@ bool LLAres::process(U64 timeout)
apr_socket_t *aprSock = NULL;
- status = apr_os_sock_put(&aprSock, (apr_os_sock_t *) &socks[i], pool);
+ status = apr_os_sock_put(&aprSock, (apr_os_sock_t *) &socks[i], pool.getAPRPool());
if (status != APR_SUCCESS)
{
ll_apr_warn_status(status);
- goto bail_pool;
+ return nsds > 0;
}
aprFds[nactive].desc.s = aprSock;
aprFds[nactive].desc_type = APR_POLL_SOCKET;
- aprFds[nactive].p = pool;
+ aprFds[nactive].p = pool.getAPRPool();
aprFds[nactive].rtnevents = 0;
aprFds[nactive].client_data = &socks[i];
@@ -530,10 +539,6 @@ bool LLAres::process(U64 timeout)
}
}
-bail_pool:
- apr_pool_destroy(pool);
-
-bail:
return nsds > 0;
}
@@ -633,8 +638,10 @@ LLPtrRecord::LLPtrRecord(const std::string &name, unsigned ttl)
}
LLAddrRecord::LLAddrRecord(LLResType type, const std::string &name,
- unsigned ttl)
- : LLDnsRecord(type, name, ttl)
+ unsigned ttl)
+ : LLDnsRecord(type, name, ttl),
+
+ mSize(0)
{
}
@@ -693,7 +700,11 @@ bail:
}
LLSrvRecord::LLSrvRecord(const std::string &name, unsigned ttl)
- : LLHostRecord(RES_SRV, name, ttl)
+ : LLHostRecord(RES_SRV, name, ttl),
+
+ mPriority(0),
+ mWeight(0),
+ mPort(0)
{
}