summaryrefslogtreecommitdiff
path: root/indra/llplugin
diff options
context:
space:
mode:
authorOz Linden <oz@lindenlab.com>2011-09-02 13:48:29 -0400
committerOz Linden <oz@lindenlab.com>2011-09-02 13:48:29 -0400
commit0ab6eee0996c78d32b722157140cea5a21a5e460 (patch)
tree2a0e90651e3cb0e236c9091b33c64d2cb7a616f7 /indra/llplugin
parentfcc51bd5b01f2a383ad057898484ac9938219b11 (diff)
parent8efd992d508eecec42648af4a7bb980fc0cc19cc (diff)
merge changes for storm-1027
Diffstat (limited to 'indra/llplugin')
-rw-r--r--indra/llplugin/llplugininstance.cpp6
-rw-r--r--indra/llplugin/llplugininstance.h2
-rw-r--r--indra/llplugin/llpluginmessagepipe.cpp2
-rw-r--r--indra/llplugin/llpluginprocesschild.cpp2
-rw-r--r--indra/llplugin/llpluginprocessparent.cpp57
-rw-r--r--indra/llplugin/llpluginprocessparent.h2
-rw-r--r--indra/llplugin/llpluginsharedmemory.cpp9
-rw-r--r--indra/llplugin/llpluginsharedmemory.h3
-rw-r--r--indra/llplugin/slplugin/slplugin.cpp4
9 files changed, 40 insertions, 47 deletions
diff --git a/indra/llplugin/llplugininstance.cpp b/indra/llplugin/llplugininstance.cpp
index 7cde82a20e..e8efb233ff 100644
--- a/indra/llplugin/llplugininstance.cpp
+++ b/indra/llplugin/llplugininstance.cpp
@@ -29,8 +29,7 @@
#include "linden_common.h"
#include "llplugininstance.h"
-
-#include "llapr.h"
+#include "llthread.h" // Needed for LLThread::tldata().mRootPool
#if LL_WINDOWS
#include "direct.h" // needed for _chdir()
@@ -52,6 +51,7 @@ const char *LLPluginInstance::PLUGIN_INIT_FUNCTION_NAME = "LLPluginInitEntryPoin
* @param[in] owner Plugin instance. TODO:DOC is this a good description of what "owner" is?
*/
LLPluginInstance::LLPluginInstance(LLPluginInstanceMessageListener *owner) :
+ mDSOHandlePool(LLThread::tldata().mRootPool),
mDSOHandle(NULL),
mPluginUserData(NULL),
mPluginSendMessageFunction(NULL)
@@ -97,7 +97,7 @@ int LLPluginInstance::load(const std::string& plugin_dir, std::string &plugin_fi
int result = apr_dso_load(&mDSOHandle,
plugin_file.c_str(),
- gAPRPoolp);
+ mDSOHandlePool());
if(result != APR_SUCCESS)
{
char buf[1024];
diff --git a/indra/llplugin/llplugininstance.h b/indra/llplugin/llplugininstance.h
index 3643a15d8c..ee28f68e83 100644
--- a/indra/llplugin/llplugininstance.h
+++ b/indra/llplugin/llplugininstance.h
@@ -30,6 +30,7 @@
#include "llstring.h"
#include "llapr.h"
+#include "llaprpool.h"
#include "apr_dso.h"
@@ -88,6 +89,7 @@ private:
static void staticReceiveMessage(const char *message_string, void **user_data);
void receiveMessage(const char *message_string);
+ LLAPRPool mDSOHandlePool;
apr_dso_handle_t *mDSOHandle;
void *mPluginUserData;
diff --git a/indra/llplugin/llpluginmessagepipe.cpp b/indra/llplugin/llpluginmessagepipe.cpp
index 8d13e38ad5..dd47300b9c 100644
--- a/indra/llplugin/llpluginmessagepipe.cpp
+++ b/indra/llplugin/llpluginmessagepipe.cpp
@@ -92,8 +92,6 @@ void LLPluginMessagePipeOwner::killMessagePipe(void)
}
LLPluginMessagePipe::LLPluginMessagePipe(LLPluginMessagePipeOwner *owner, LLSocket::ptr_t socket):
- mInputMutex(gAPRPoolp),
- mOutputMutex(gAPRPoolp),
mOwner(owner),
mSocket(socket)
{
diff --git a/indra/llplugin/llpluginprocesschild.cpp b/indra/llplugin/llpluginprocesschild.cpp
index f8a282184e..fd63fdde81 100644
--- a/indra/llplugin/llpluginprocesschild.cpp
+++ b/indra/llplugin/llpluginprocesschild.cpp
@@ -40,7 +40,7 @@ LLPluginProcessChild::LLPluginProcessChild()
{
mState = STATE_UNINITIALIZED;
mInstance = NULL;
- mSocket = LLSocket::create(gAPRPoolp, LLSocket::STREAM_TCP);
+ mSocket = LLSocket::create(LLSocket::STREAM_TCP);
mSleepTime = PLUGIN_IDLE_SECONDS; // default: send idle messages at 100Hz
mCPUElapsed = 0.0f;
mBlockingRequest = false;
diff --git a/indra/llplugin/llpluginprocessparent.cpp b/indra/llplugin/llpluginprocessparent.cpp
index 110fac0f23..7aec72731e 100644
--- a/indra/llplugin/llpluginprocessparent.cpp
+++ b/indra/llplugin/llpluginprocessparent.cpp
@@ -33,6 +33,7 @@
#include "llpluginmessageclasses.h"
#include "llapr.h"
+#include "llscopedvolatileaprpool.h"
//virtual
LLPluginProcessParentOwner::~LLPluginProcessParentOwner()
@@ -42,6 +43,7 @@ LLPluginProcessParentOwner::~LLPluginProcessParentOwner()
bool LLPluginProcessParent::sUseReadThread = false;
apr_pollset_t *LLPluginProcessParent::sPollSet = NULL;
+LLAPRPool LLPluginProcessParent::sPollSetPool;
bool LLPluginProcessParent::sPollsetNeedsRebuild = false;
LLMutex *LLPluginProcessParent::sInstancesMutex;
std::list<LLPluginProcessParent*> LLPluginProcessParent::sInstances;
@@ -52,7 +54,7 @@ class LLPluginProcessParentPollThread: public LLThread
{
public:
LLPluginProcessParentPollThread() :
- LLThread("LLPluginProcessParentPollThread", gAPRPoolp)
+ LLThread("LLPluginProcessParentPollThread")
{
}
protected:
@@ -77,12 +79,11 @@ protected:
};
-LLPluginProcessParent::LLPluginProcessParent(LLPluginProcessParentOwner *owner):
- mIncomingQueueMutex(gAPRPoolp)
+LLPluginProcessParent::LLPluginProcessParent(LLPluginProcessParentOwner* owner)
{
if(!sInstancesMutex)
{
- sInstancesMutex = new LLMutex(gAPRPoolp);
+ sInstancesMutex = new LLMutex;
}
mOwner = owner;
@@ -95,6 +96,7 @@ LLPluginProcessParent::LLPluginProcessParent(LLPluginProcessParentOwner *owner):
mBlocked = false;
mPolledInput = false;
mPollFD.client_data = NULL;
+ mPollFDPool.create();
mPluginLaunchTimeout = 60.0f;
mPluginLockupTimeout = 15.0f;
@@ -171,44 +173,28 @@ void LLPluginProcessParent::init(const std::string &launcher_filename, const std
bool LLPluginProcessParent::accept()
{
bool result = false;
-
apr_status_t status = APR_EGENERAL;
- apr_socket_t *new_socket = NULL;
-
- status = apr_socket_accept(
- &new_socket,
- mListenSocket->getSocket(),
- gAPRPoolp);
+ mSocket = LLSocket::create(status, mListenSocket);
if(status == APR_SUCCESS)
{
// llinfos << "SUCCESS" << llendl;
// Success. Create a message pipe on the new socket
-
- // we MUST create a new pool for the LLSocket, since it will take ownership of it and delete it in its destructor!
- apr_pool_t* new_pool = NULL;
- status = apr_pool_create(&new_pool, gAPRPoolp);
-
- mSocket = LLSocket::create(new_socket, new_pool);
new LLPluginMessagePipe(this, mSocket);
result = true;
}
- else if(APR_STATUS_IS_EAGAIN(status))
- {
-// llinfos << "EAGAIN" << llendl;
-
- // No incoming connections. This is not an error.
- status = APR_SUCCESS;
- }
else
{
-// llinfos << "Error:" << llendl;
- ll_apr_warn_status(status);
-
- // Some other error.
- errorState();
+ mSocket.reset();
+ // EAGAIN means "No incoming connections". This is not an error.
+ if (!APR_STATUS_IS_EAGAIN(status))
+ {
+ // Some other error.
+ ll_apr_warn_status(status);
+ errorState();
+ }
}
return result;
@@ -274,10 +260,10 @@ void LLPluginProcessParent::idle(void)
case STATE_INITIALIZED:
{
-
apr_status_t status = APR_SUCCESS;
+ LLScopedVolatileAPRPool addr_pool;
apr_sockaddr_t* addr = NULL;
- mListenSocket = LLSocket::create(gAPRPoolp, LLSocket::STREAM_TCP);
+ mListenSocket = LLSocket::create(LLSocket::STREAM_TCP);
mBoundPort = 0;
// This code is based on parts of LLSocket::create() in lliosocket.cpp.
@@ -288,7 +274,7 @@ void LLPluginProcessParent::idle(void)
APR_INET,
0, // port 0 = ephemeral ("find me a port")
0,
- gAPRPoolp);
+ addr_pool);
if(ll_apr_warn_status(status))
{
@@ -601,7 +587,7 @@ void LLPluginProcessParent::setMessagePipe(LLPluginMessagePipe *message_pipe)
if(message_pipe != NULL)
{
// Set up the apr_pollfd_t
- mPollFD.p = gAPRPoolp;
+ mPollFD.p = mPollFDPool();
mPollFD.desc_type = APR_POLL_SOCKET;
mPollFD.reqevents = APR_POLLIN|APR_POLLERR|APR_POLLHUP;
mPollFD.rtnevents = 0;
@@ -648,6 +634,7 @@ void LLPluginProcessParent::updatePollset()
// delete the existing pollset.
apr_pollset_destroy(sPollSet);
sPollSet = NULL;
+ sPollSetPool.destroy();
}
std::list<LLPluginProcessParent*>::iterator iter;
@@ -670,12 +657,14 @@ void LLPluginProcessParent::updatePollset()
{
#ifdef APR_POLLSET_NOCOPY
// The pollset doesn't exist yet. Create it now.
- apr_status_t status = apr_pollset_create(&sPollSet, count, gAPRPoolp, APR_POLLSET_NOCOPY);
+ sPollSetPool.create();
+ apr_status_t status = apr_pollset_create(&sPollSet, count, sPollSetPool(), APR_POLLSET_NOCOPY);
if(status != APR_SUCCESS)
{
#endif // APR_POLLSET_NOCOPY
LL_WARNS("PluginPoll") << "Couldn't create pollset. Falling back to non-pollset mode." << LL_ENDL;
sPollSet = NULL;
+ sPollSetPool.destroy();
#ifdef APR_POLLSET_NOCOPY
}
else
diff --git a/indra/llplugin/llpluginprocessparent.h b/indra/llplugin/llpluginprocessparent.h
index 26c6b0c402..74b7e9f50c 100644
--- a/indra/llplugin/llpluginprocessparent.h
+++ b/indra/llplugin/llpluginprocessparent.h
@@ -178,7 +178,9 @@ private:
static bool sUseReadThread;
apr_pollfd_t mPollFD;
+ LLAPRPool mPollFDPool;
static apr_pollset_t *sPollSet;
+ static LLAPRPool sPollSetPool;
static bool sPollsetNeedsRebuild;
static LLMutex *sInstancesMutex;
static std::list<LLPluginProcessParent*> sInstances;
diff --git a/indra/llplugin/llpluginsharedmemory.cpp b/indra/llplugin/llpluginsharedmemory.cpp
index 63ff5085c6..e2ff645a9c 100644
--- a/indra/llplugin/llpluginsharedmemory.cpp
+++ b/indra/llplugin/llpluginsharedmemory.cpp
@@ -187,7 +187,8 @@ bool LLPluginSharedMemory::create(size_t size)
mName += createName();
mSize = size;
- apr_status_t status = apr_shm_create( &(mImpl->mAprSharedMemory), mSize, mName.c_str(), gAPRPoolp );
+ mPool.create();
+ apr_status_t status = apr_shm_create( &(mImpl->mAprSharedMemory), mSize, mName.c_str(), mPool());
if(ll_apr_warn_status(status))
{
@@ -210,7 +211,7 @@ bool LLPluginSharedMemory::destroy(void)
}
mImpl->mAprSharedMemory = NULL;
}
-
+ mPool.destroy();
return true;
}
@@ -219,7 +220,8 @@ bool LLPluginSharedMemory::attach(const std::string &name, size_t size)
mName = name;
mSize = size;
- apr_status_t status = apr_shm_attach( &(mImpl->mAprSharedMemory), mName.c_str(), gAPRPoolp );
+ mPool.create();
+ apr_status_t status = apr_shm_attach( &(mImpl->mAprSharedMemory), mName.c_str(), mPool() );
if(ll_apr_warn_status(status))
{
@@ -241,6 +243,7 @@ bool LLPluginSharedMemory::detach(void)
}
mImpl->mAprSharedMemory = NULL;
}
+ mPool.destroy();
return true;
}
diff --git a/indra/llplugin/llpluginsharedmemory.h b/indra/llplugin/llpluginsharedmemory.h
index c6cd49cabb..84b7a58c32 100644
--- a/indra/llplugin/llpluginsharedmemory.h
+++ b/indra/llplugin/llpluginsharedmemory.h
@@ -28,6 +28,8 @@
#ifndef LL_LLPLUGINSHAREDMEMORY_H
#define LL_LLPLUGINSHAREDMEMORY_H
+#include "llaprpool.h"
+
class LLPluginSharedMemoryPlatformImpl;
/**
@@ -108,6 +110,7 @@ private:
bool close(void);
bool unlink(void);
+ LLAPRPool mPool;
std::string mName;
size_t mSize;
void *mMappedAddress;
diff --git a/indra/llplugin/slplugin/slplugin.cpp b/indra/llplugin/slplugin/slplugin.cpp
index 516a58db88..ff86e4e135 100644
--- a/indra/llplugin/slplugin/slplugin.cpp
+++ b/indra/llplugin/slplugin/slplugin.cpp
@@ -176,8 +176,6 @@ int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL
int main(int argc, char **argv)
#endif
{
- ll_init_apr();
-
// Set up llerror logging
{
LLError::initForApplication(".");
@@ -393,8 +391,6 @@ int main(int argc, char **argv)
delete plugin;
- ll_cleanup_apr();
-
return 0;
}