aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage/llares.cpp
diff options
context:
space:
mode:
authorAleric Inglewood2010-11-10 15:19:13 +0100
committerAleric Inglewood2010-11-17 01:03:18 +0100
commitb66950bc26cfb3210e786c966141b20a5cc13a84 (patch)
tree5afd535bfd59f1fb1fc6d9132958965c527aa0ee /linden/indra/llmessage/llares.cpp
parentIMP-712: Add shortcut for the Groups tab. (diff)
downloadmeta-impy-b66950bc26cfb3210e786c966141b20a5cc13a84.zip
meta-impy-b66950bc26cfb3210e786c966141b20a5cc13a84.tar.gz
meta-impy-b66950bc26cfb3210e786c966141b20a5cc13a84.tar.bz2
meta-impy-b66950bc26cfb3210e786c966141b20a5cc13a84.tar.xz
IMP-590: Added a thread-safe and robust wrapper for APR pools.
See http://redmine.imprudenceviewer.org/issues/590
Diffstat (limited to '')
-rw-r--r--linden/indra/llmessage/llares.cpp17
1 files changed, 5 insertions, 12 deletions
diff --git a/linden/indra/llmessage/llares.cpp b/linden/indra/llmessage/llares.cpp
index fe37fe8..5a6794e 100644
--- a/linden/indra/llmessage/llares.cpp
+++ b/linden/indra/llmessage/llares.cpp
@@ -43,6 +43,7 @@
43 43
44#include "llapr.h" 44#include "llapr.h"
45#include "llares.h" 45#include "llares.h"
46#include "llscopedvolatileaprpool.h"
46 47
47#if defined(LL_WINDOWS) 48#if defined(LL_WINDOWS)
48# define ns_c_in 1 49# define ns_c_in 1
@@ -463,11 +464,6 @@ void LLAres::search(const std::string &query, LLResType type,
463 464
464bool LLAres::process(U64 timeout) 465bool LLAres::process(U64 timeout)
465{ 466{
466 if (!gAPRPoolp)
467 {
468 ll_init_apr();
469 }
470
471 int socks[ARES_GETSOCK_MAXNUM]; 467 int socks[ARES_GETSOCK_MAXNUM];
472 apr_pollfd_t aprFds[ARES_GETSOCK_MAXNUM]; 468 apr_pollfd_t aprFds[ARES_GETSOCK_MAXNUM];
473 apr_int32_t nsds = 0; 469 apr_int32_t nsds = 0;
@@ -481,10 +477,7 @@ bool LLAres::process(U64 timeout)
481 return nsds > 0; 477 return nsds > 0;
482 } 478 }
483 479
484 apr_status_t status; 480 LLScopedVolatileAPRPool scoped_pool;
485 LLAPRPool pool;
486 status = pool.getStatus() ;
487 ll_apr_assert_status(status);
488 481
489 for (int i = 0; i < ARES_GETSOCK_MAXNUM; i++) 482 for (int i = 0; i < ARES_GETSOCK_MAXNUM; i++)
490 { 483 {
@@ -501,7 +494,7 @@ bool LLAres::process(U64 timeout)
501 494
502 apr_socket_t *aprSock = NULL; 495 apr_socket_t *aprSock = NULL;
503 496
504 status = apr_os_sock_put(&aprSock, (apr_os_sock_t *) &socks[i], pool.getAPRPool()); 497 apr_status_t status = apr_os_sock_put(&aprSock, (apr_os_sock_t *) &socks[i], scoped_pool);
505 if (status != APR_SUCCESS) 498 if (status != APR_SUCCESS)
506 { 499 {
507 ll_apr_warn_status(status); 500 ll_apr_warn_status(status);
@@ -510,7 +503,7 @@ bool LLAres::process(U64 timeout)
510 503
511 aprFds[nactive].desc.s = aprSock; 504 aprFds[nactive].desc.s = aprSock;
512 aprFds[nactive].desc_type = APR_POLL_SOCKET; 505 aprFds[nactive].desc_type = APR_POLL_SOCKET;
513 aprFds[nactive].p = pool.getAPRPool(); 506 aprFds[nactive].p = scoped_pool;
514 aprFds[nactive].rtnevents = 0; 507 aprFds[nactive].rtnevents = 0;
515 aprFds[nactive].client_data = &socks[i]; 508 aprFds[nactive].client_data = &socks[i];
516 509
@@ -519,7 +512,7 @@ bool LLAres::process(U64 timeout)
519 512
520 if (nactive > 0) 513 if (nactive > 0)
521 { 514 {
522 status = apr_poll(aprFds, nactive, &nsds, timeout); 515 apr_status_t status = apr_poll(aprFds, nactive, &nsds, timeout);
523 516
524 if (status != APR_SUCCESS && status != APR_TIMEUP) 517 if (status != APR_SUCCESS && status != APR_TIMEUP)
525 { 518 {