Added a thread-safe and robust wrapper for APR pools.

See http://redmine.imprudenceviewer.org/issues/590
and https://jira.secondlife.com/browse/SNOW-596
This commit is contained in:
Aleric Inglewood
2011-05-05 01:34:00 +02:00
parent 5b08560047
commit 4d932d5e2d
57 changed files with 895 additions and 751 deletions

View File

@@ -44,6 +44,7 @@
#include "llapr.h"
#define CARES_STATICLIB
#include "llares.h"
#include "llscopedvolatileaprpool.h"
#if defined(LL_WINDOWS)
# define ns_c_in 1
@@ -467,11 +468,6 @@ void LLAres::search(const std::string &query, LLResType type,
bool LLAres::process(U64 timeout)
{
if (!gAPRPoolp)
{
ll_init_apr();
}
ares_socket_t socks[ARES_GETSOCK_MAXNUM];
apr_pollfd_t aprFds[ARES_GETSOCK_MAXNUM];
apr_int32_t nsds = 0;
@@ -485,10 +481,7 @@ bool LLAres::process(U64 timeout)
return nsds > 0;
}
apr_status_t status;
LLAPRPool pool;
status = pool.getStatus() ;
ll_apr_assert_status(status);
LLScopedVolatileAPRPool scoped_pool;
for (int i = 0; i < ARES_GETSOCK_MAXNUM; i++)
{
@@ -505,7 +498,7 @@ bool LLAres::process(U64 timeout)
apr_socket_t *aprSock = NULL;
status = apr_os_sock_put(&aprSock, (apr_os_sock_t *) &socks[i], pool.getAPRPool());
apr_status_t status = apr_os_sock_put(&aprSock, (apr_os_sock_t *) &socks[i], scoped_pool);
if (status != APR_SUCCESS)
{
ll_apr_warn_status(status);
@@ -514,7 +507,7 @@ bool LLAres::process(U64 timeout)
aprFds[nactive].desc.s = aprSock;
aprFds[nactive].desc_type = APR_POLL_SOCKET;
aprFds[nactive].p = pool.getAPRPool();
aprFds[nactive].p = scoped_pool;
aprFds[nactive].rtnevents = 0;
aprFds[nactive].client_data = &socks[i];
@@ -523,7 +516,7 @@ bool LLAres::process(U64 timeout)
if (nactive > 0)
{
status = apr_poll(aprFds, nactive, &nsds, timeout);
apr_status_t status = apr_poll(aprFds, nactive, &nsds, timeout);
if (status != APR_SUCCESS && status != APR_TIMEUP)
{