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:
@@ -50,7 +50,7 @@ extern "C" {
|
||||
#include <pulse/subscribe.h>
|
||||
#include <pulse/glib-mainloop.h> // There's no special reason why we want the *glib* PA mainloop, but the generic polling implementation seems broken.
|
||||
|
||||
#include "apr_pools.h"
|
||||
#include "aiaprpool.h"
|
||||
#include "apr_dso.h"
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ extern "C" {
|
||||
#undef LL_PA_SYM
|
||||
|
||||
static bool sSymsGrabbed = false;
|
||||
static apr_pool_t *sSymPADSOMemoryPool = NULL;
|
||||
static AIAPRPool sSymPADSOMemoryPool;
|
||||
static apr_dso_handle_t *sSymPADSOHandleG = NULL;
|
||||
|
||||
bool grab_pa_syms(std::string pulse_dso_name)
|
||||
@@ -85,11 +85,11 @@ bool grab_pa_syms(std::string pulse_dso_name)
|
||||
#define LL_PA_SYM(REQUIRED, PASYM, RTN, ...) do{rv = apr_dso_sym((apr_dso_handle_sym_t*)&ll##PASYM, sSymPADSOHandle, #PASYM); if (rv != APR_SUCCESS) {INFOMSG("Failed to grab symbol: %s", #PASYM); if (REQUIRED) sym_error = true;} else DEBUGMSG("grabbed symbol: %s from %p", #PASYM, (void*)ll##PASYM);}while(0)
|
||||
|
||||
//attempt to load the shared library
|
||||
apr_pool_create(&sSymPADSOMemoryPool, NULL);
|
||||
sSymPADSOMemoryPool.create();
|
||||
|
||||
if ( APR_SUCCESS == (rv = apr_dso_load(&sSymPADSOHandle,
|
||||
pulse_dso_name.c_str(),
|
||||
sSymPADSOMemoryPool) ))
|
||||
sSymPADSOMemoryPool()) ))
|
||||
{
|
||||
INFOMSG("Found DSO: %s", pulse_dso_name.c_str());
|
||||
|
||||
@@ -132,11 +132,7 @@ void ungrab_pa_syms()
|
||||
sSymPADSOHandleG = NULL;
|
||||
}
|
||||
|
||||
if ( sSymPADSOMemoryPool )
|
||||
{
|
||||
apr_pool_destroy(sSymPADSOMemoryPool);
|
||||
sSymPADSOMemoryPool = NULL;
|
||||
}
|
||||
sSymPADSOMemoryPool.destroy();
|
||||
|
||||
// NULL-out all of the symbols we'd grabbed
|
||||
#define LL_PA_SYM(REQUIRED, PASYM, RTN, ...) do{ll##PASYM = NULL;}while(0)
|
||||
|
||||
Reference in New Issue
Block a user