From 4331c112aba074562e9a8826fe6d271a94f790f0 Mon Sep 17 00:00:00 2001 From: Dave Parks Date: Fri, 14 Oct 2011 11:52:40 -0500 Subject: Backed out changeset b782a75c99e6 --- indra/llplugin/llplugininstance.cpp | 6 ++-- indra/llplugin/llplugininstance.h | 2 -- indra/llplugin/llpluginmessagepipe.cpp | 2 ++ indra/llplugin/llpluginprocesschild.cpp | 2 +- indra/llplugin/llpluginprocessparent.cpp | 57 +++++++++++++++++++------------- indra/llplugin/llpluginprocessparent.h | 2 -- indra/llplugin/llpluginsharedmemory.cpp | 9 ++--- indra/llplugin/llpluginsharedmemory.h | 3 -- indra/llplugin/slplugin/slplugin.cpp | 4 +++ 9 files changed, 47 insertions(+), 40 deletions(-) (limited to 'indra/llplugin') diff --git a/indra/llplugin/llplugininstance.cpp b/indra/llplugin/llplugininstance.cpp index 9c9909a017..c326961db4 100644 --- a/indra/llplugin/llplugininstance.cpp +++ b/indra/llplugin/llplugininstance.cpp @@ -29,7 +29,8 @@ #include "linden_common.h" #include "llplugininstance.h" -#include "llthread.h" // Needed for LLThread::tldata().mRootPool + +#include "llapr.h" /** Virtual destructor. */ LLPluginInstanceMessageListener::~LLPluginInstanceMessageListener() @@ -47,7 +48,6 @@ 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) @@ -79,7 +79,7 @@ int LLPluginInstance::load(std::string &plugin_file) int result = apr_dso_load(&mDSOHandle, plugin_file.c_str(), - mDSOHandlePool()); + gAPRPoolp); if(result != APR_SUCCESS) { char buf[1024]; diff --git a/indra/llplugin/llplugininstance.h b/indra/llplugin/llplugininstance.h index 1c3898e2e7..50531ca77f 100644 --- a/indra/llplugin/llplugininstance.h +++ b/indra/llplugin/llplugininstance.h @@ -30,7 +30,6 @@ #include "llstring.h" #include "llapr.h" -#include "llaprpool.h" #include "apr_dso.h" @@ -89,7 +88,6 @@ 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 dd47300b9c..8d13e38ad5 100644 --- a/indra/llplugin/llpluginmessagepipe.cpp +++ b/indra/llplugin/llpluginmessagepipe.cpp @@ -92,6 +92,8 @@ 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 2fa5dcdd01..45a86476ac 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(LLSocket::STREAM_TCP); + mSocket = LLSocket::create(gAPRPoolp, 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 eaf7ec4bf3..c002de0462 100644 --- a/indra/llplugin/llpluginprocessparent.cpp +++ b/indra/llplugin/llpluginprocessparent.cpp @@ -33,7 +33,6 @@ #include "llpluginmessageclasses.h" #include "llapr.h" -#include "llscopedvolatileaprpool.h" //virtual LLPluginProcessParentOwner::~LLPluginProcessParentOwner() @@ -43,7 +42,6 @@ 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::sInstances; @@ -54,7 +52,7 @@ class LLPluginProcessParentPollThread: public LLThread { public: LLPluginProcessParentPollThread() : - LLThread("LLPluginProcessParentPollThread") + LLThread("LLPluginProcessParentPollThread", gAPRPoolp) { } protected: @@ -79,11 +77,12 @@ protected: }; -LLPluginProcessParent::LLPluginProcessParent(LLPluginProcessParentOwner* owner) +LLPluginProcessParent::LLPluginProcessParent(LLPluginProcessParentOwner *owner): + mIncomingQueueMutex(gAPRPoolp) { if(!sInstancesMutex) { - sInstancesMutex = new LLMutex; + sInstancesMutex = new LLMutex(gAPRPoolp); } mOwner = owner; @@ -96,7 +95,6 @@ LLPluginProcessParent::LLPluginProcessParent(LLPluginProcessParentOwner* owner) mBlocked = false; mPolledInput = false; mPollFD.client_data = NULL; - mPollFDPool.create(); mPluginLaunchTimeout = 60.0f; mPluginLockupTimeout = 15.0f; @@ -171,28 +169,44 @@ 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 { - 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(); - } +// llinfos << "Error:" << llendl; + ll_apr_warn_status(status); + + // Some other error. + errorState(); } return result; @@ -258,10 +272,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(LLSocket::STREAM_TCP); + mListenSocket = LLSocket::create(gAPRPoolp, LLSocket::STREAM_TCP); mBoundPort = 0; // This code is based on parts of LLSocket::create() in lliosocket.cpp. @@ -272,7 +286,7 @@ void LLPluginProcessParent::idle(void) APR_INET, 0, // port 0 = ephemeral ("find me a port") 0, - addr_pool); + gAPRPoolp); if(ll_apr_warn_status(status)) { @@ -584,7 +598,7 @@ void LLPluginProcessParent::setMessagePipe(LLPluginMessagePipe *message_pipe) if(message_pipe != NULL) { // Set up the apr_pollfd_t - mPollFD.p = mPollFDPool(); + mPollFD.p = gAPRPoolp; mPollFD.desc_type = APR_POLL_SOCKET; mPollFD.reqevents = APR_POLLIN|APR_POLLERR|APR_POLLHUP; mPollFD.rtnevents = 0; @@ -631,7 +645,6 @@ void LLPluginProcessParent::updatePollset() // delete the existing pollset. apr_pollset_destroy(sPollSet); sPollSet = NULL; - sPollSetPool.destroy(); } std::list::iterator iter; @@ -654,14 +667,12 @@ void LLPluginProcessParent::updatePollset() { #ifdef APR_POLLSET_NOCOPY // The pollset doesn't exist yet. Create it now. - sPollSetPool.create(); - apr_status_t status = apr_pollset_create(&sPollSet, count, sPollSetPool(), APR_POLLSET_NOCOPY); + apr_status_t status = apr_pollset_create(&sPollSet, count, gAPRPoolp, 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 6beeb64c7e..32394809ef 100644 --- a/indra/llplugin/llpluginprocessparent.h +++ b/indra/llplugin/llpluginprocessparent.h @@ -176,9 +176,7 @@ 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 sInstances; diff --git a/indra/llplugin/llpluginsharedmemory.cpp b/indra/llplugin/llpluginsharedmemory.cpp index e2ff645a9c..63ff5085c6 100644 --- a/indra/llplugin/llpluginsharedmemory.cpp +++ b/indra/llplugin/llpluginsharedmemory.cpp @@ -187,8 +187,7 @@ bool LLPluginSharedMemory::create(size_t size) mName += createName(); mSize = size; - mPool.create(); - apr_status_t status = apr_shm_create( &(mImpl->mAprSharedMemory), mSize, mName.c_str(), mPool()); + apr_status_t status = apr_shm_create( &(mImpl->mAprSharedMemory), mSize, mName.c_str(), gAPRPoolp ); if(ll_apr_warn_status(status)) { @@ -211,7 +210,7 @@ bool LLPluginSharedMemory::destroy(void) } mImpl->mAprSharedMemory = NULL; } - mPool.destroy(); + return true; } @@ -220,8 +219,7 @@ bool LLPluginSharedMemory::attach(const std::string &name, size_t size) mName = name; mSize = size; - mPool.create(); - apr_status_t status = apr_shm_attach( &(mImpl->mAprSharedMemory), mName.c_str(), mPool() ); + apr_status_t status = apr_shm_attach( &(mImpl->mAprSharedMemory), mName.c_str(), gAPRPoolp ); if(ll_apr_warn_status(status)) { @@ -243,7 +241,6 @@ bool LLPluginSharedMemory::detach(void) } mImpl->mAprSharedMemory = NULL; } - mPool.destroy(); return true; } diff --git a/indra/llplugin/llpluginsharedmemory.h b/indra/llplugin/llpluginsharedmemory.h index 84b7a58c32..c6cd49cabb 100644 --- a/indra/llplugin/llpluginsharedmemory.h +++ b/indra/llplugin/llpluginsharedmemory.h @@ -28,8 +28,6 @@ #ifndef LL_LLPLUGINSHAREDMEMORY_H #define LL_LLPLUGINSHAREDMEMORY_H -#include "llaprpool.h" - class LLPluginSharedMemoryPlatformImpl; /** @@ -110,7 +108,6 @@ 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 ff86e4e135..516a58db88 100644 --- a/indra/llplugin/slplugin/slplugin.cpp +++ b/indra/llplugin/slplugin/slplugin.cpp @@ -176,6 +176,8 @@ 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("."); @@ -391,6 +393,8 @@ int main(int argc, char **argv) delete plugin; + ll_cleanup_apr(); + return 0; } -- cgit v1.2.3