aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llplugin
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llplugin')
-rwxr-xr-xlinden/indra/llplugin/llplugininstance.cpp5
-rwxr-xr-xlinden/indra/llplugin/llpluginmessagepipe.cpp2
-rwxr-xr-xlinden/indra/llplugin/llpluginprocesschild.cpp2
-rwxr-xr-xlinden/indra/llplugin/llpluginprocessparent.cpp55
-rwxr-xr-xlinden/indra/llplugin/llpluginprocessparent.h2
-rwxr-xr-xlinden/indra/llplugin/llpluginsharedmemory.cpp9
-rwxr-xr-xlinden/indra/llplugin/llpluginsharedmemory.h3
-rwxr-xr-xlinden/indra/llplugin/slplugin/slplugin.cpp4
8 files changed, 36 insertions, 46 deletions
diff --git a/linden/indra/llplugin/llplugininstance.cpp b/linden/indra/llplugin/llplugininstance.cpp
index b822b9e..3a1395c 100755
--- a/linden/indra/llplugin/llplugininstance.cpp
+++ b/linden/indra/llplugin/llplugininstance.cpp
@@ -36,8 +36,7 @@
36#include "linden_common.h" 36#include "linden_common.h"
37 37
38#include "llplugininstance.h" 38#include "llplugininstance.h"
39 39#include "aiaprpool.h"
40#include "llapr.h"
41 40
42/** Virtual destructor. */ 41/** Virtual destructor. */
43LLPluginInstanceMessageListener::~LLPluginInstanceMessageListener() 42LLPluginInstanceMessageListener::~LLPluginInstanceMessageListener()
@@ -86,7 +85,7 @@ int LLPluginInstance::load(std::string &plugin_file)
86 85
87 int result = apr_dso_load(&mDSOHandle, 86 int result = apr_dso_load(&mDSOHandle,
88 plugin_file.c_str(), 87 plugin_file.c_str(),
89 gAPRPoolp); 88 AIAPRRootPool::get()());
90 if(result != APR_SUCCESS) 89 if(result != APR_SUCCESS)
91 { 90 {
92 char buf[1024]; 91 char buf[1024];
diff --git a/linden/indra/llplugin/llpluginmessagepipe.cpp b/linden/indra/llplugin/llpluginmessagepipe.cpp
index 8168b32..ebac3c5 100755
--- a/linden/indra/llplugin/llpluginmessagepipe.cpp
+++ b/linden/indra/llplugin/llpluginmessagepipe.cpp
@@ -99,8 +99,6 @@ void LLPluginMessagePipeOwner::killMessagePipe(void)
99} 99}
100 100
101LLPluginMessagePipe::LLPluginMessagePipe(LLPluginMessagePipeOwner *owner, LLSocket::ptr_t socket): 101LLPluginMessagePipe::LLPluginMessagePipe(LLPluginMessagePipeOwner *owner, LLSocket::ptr_t socket):
102 mInputMutex(gAPRPoolp),
103 mOutputMutex(gAPRPoolp),
104 mOwner(owner), 102 mOwner(owner),
105 mSocket(socket) 103 mSocket(socket)
106{ 104{
diff --git a/linden/indra/llplugin/llpluginprocesschild.cpp b/linden/indra/llplugin/llpluginprocesschild.cpp
index 8dbf2b3..d223823 100755
--- a/linden/indra/llplugin/llpluginprocesschild.cpp
+++ b/linden/indra/llplugin/llpluginprocesschild.cpp
@@ -47,7 +47,7 @@ LLPluginProcessChild::LLPluginProcessChild()
47{ 47{
48 mState = STATE_UNINITIALIZED; 48 mState = STATE_UNINITIALIZED;
49 mInstance = NULL; 49 mInstance = NULL;
50 mSocket = LLSocket::create(gAPRPoolp, LLSocket::STREAM_TCP); 50 mSocket = LLSocket::create(LLSocket::STREAM_TCP);
51 mSleepTime = PLUGIN_IDLE_SECONDS; // default: send idle messages at 100Hz 51 mSleepTime = PLUGIN_IDLE_SECONDS; // default: send idle messages at 100Hz
52 mCPUElapsed = 0.0f; 52 mCPUElapsed = 0.0f;
53 mBlockingRequest = false; 53 mBlockingRequest = false;
diff --git a/linden/indra/llplugin/llpluginprocessparent.cpp b/linden/indra/llplugin/llpluginprocessparent.cpp
index 8fd18ef..2cb6b28 100755
--- a/linden/indra/llplugin/llpluginprocessparent.cpp
+++ b/linden/indra/llplugin/llpluginprocessparent.cpp
@@ -49,6 +49,7 @@ LLPluginProcessParentOwner::~LLPluginProcessParentOwner()
49 49
50bool LLPluginProcessParent::sUseReadThread = false; 50bool LLPluginProcessParent::sUseReadThread = false;
51apr_pollset_t *LLPluginProcessParent::sPollSet = NULL; 51apr_pollset_t *LLPluginProcessParent::sPollSet = NULL;
52AIAPRPool LLPluginProcessParent::sPollSetPool;
52bool LLPluginProcessParent::sPollsetNeedsRebuild = false; 53bool LLPluginProcessParent::sPollsetNeedsRebuild = false;
53LLMutex *LLPluginProcessParent::sInstancesMutex; 54LLMutex *LLPluginProcessParent::sInstancesMutex;
54std::list<LLPluginProcessParent*> LLPluginProcessParent::sInstances; 55std::list<LLPluginProcessParent*> LLPluginProcessParent::sInstances;
@@ -59,7 +60,7 @@ class LLPluginProcessParentPollThread: public LLThread
59{ 60{
60public: 61public:
61 LLPluginProcessParentPollThread() : 62 LLPluginProcessParentPollThread() :
62 LLThread("LLPluginProcessParentPollThread", gAPRPoolp) 63 LLThread("LLPluginProcessParentPollThread")
63 { 64 {
64 } 65 }
65protected: 66protected:
@@ -84,12 +85,11 @@ protected:
84 85
85}; 86};
86 87
87LLPluginProcessParent::LLPluginProcessParent(LLPluginProcessParentOwner *owner): 88LLPluginProcessParent::LLPluginProcessParent(LLPluginProcessParentOwner *owner)
88 mIncomingQueueMutex(gAPRPoolp)
89{ 89{
90 if(!sInstancesMutex) 90 if(!sInstancesMutex)
91 { 91 {
92 sInstancesMutex = new LLMutex(gAPRPoolp); 92 sInstancesMutex = new LLMutex;
93 } 93 }
94 94
95 mOwner = owner; 95 mOwner = owner;
@@ -102,6 +102,7 @@ LLPluginProcessParent::LLPluginProcessParent(LLPluginProcessParentOwner *owner):
102 mBlocked = false; 102 mBlocked = false;
103 mPolledInput = false; 103 mPolledInput = false;
104 mPollFD.client_data = NULL; 104 mPollFD.client_data = NULL;
105 mPollFDPool.create();
105 106
106 mPluginLaunchTimeout = 60.0f; 107 mPluginLaunchTimeout = 60.0f;
107 mPluginLockupTimeout = 15.0f; 108 mPluginLockupTimeout = 15.0f;
@@ -177,44 +178,28 @@ void LLPluginProcessParent::init(const std::string &launcher_filename, const std
177bool LLPluginProcessParent::accept() 178bool LLPluginProcessParent::accept()
178{ 179{
179 bool result = false; 180 bool result = false;
180
181 apr_status_t status = APR_EGENERAL; 181 apr_status_t status = APR_EGENERAL;
182 apr_socket_t *new_socket = NULL;
183
184 status = apr_socket_accept(
185 &new_socket,
186 mListenSocket->getSocket(),
187 gAPRPoolp);
188 182
183 mSocket = LLSocket::create(status, mListenSocket);
189 184
190 if(status == APR_SUCCESS) 185 if(status == APR_SUCCESS)
191 { 186 {
192// llinfos << "SUCCESS" << llendl; 187// llinfos << "SUCCESS" << llendl;
193 // Success. Create a message pipe on the new socket 188 // Success. Create a message pipe on the new socket
194
195 // we MUST create a new pool for the LLSocket, since it will take ownership of it and delete it in its destructor!
196 apr_pool_t* new_pool = NULL;
197 status = apr_pool_create(&new_pool, gAPRPoolp);
198
199 mSocket = LLSocket::create(new_socket, new_pool);
200 new LLPluginMessagePipe(this, mSocket); 189 new LLPluginMessagePipe(this, mSocket);
201 190
202 result = true; 191 result = true;
203 } 192 }
204 else if(APR_STATUS_IS_EAGAIN(status))
205 {
206// llinfos << "EAGAIN" << llendl;
207
208 // No incoming connections. This is not an error.
209 status = APR_SUCCESS;
210 }
211 else 193 else
212 { 194 {
213// llinfos << "Error:" << llendl; 195 mSocket.reset();
214 ll_apr_warn_status(status); 196 // EAGAIN means "No incoming connections". This is not an error.
215 197 if (!APR_STATUS_IS_EAGAIN(status))
216 // Some other error. 198 {
217 errorState(); 199 // Some other error.
200 ll_apr_warn_status(status);
201 errorState();
202 }
218 } 203 }
219 204
220 return result; 205 return result;
@@ -283,7 +268,7 @@ void LLPluginProcessParent::idle(void)
283 268
284 apr_status_t status = APR_SUCCESS; 269 apr_status_t status = APR_SUCCESS;
285 apr_sockaddr_t* addr = NULL; 270 apr_sockaddr_t* addr = NULL;
286 mListenSocket = LLSocket::create(gAPRPoolp, LLSocket::STREAM_TCP); 271 mListenSocket = LLSocket::create(LLSocket::STREAM_TCP);
287 mBoundPort = 0; 272 mBoundPort = 0;
288 273
289 // This code is based on parts of LLSocket::create() in lliosocket.cpp. 274 // This code is based on parts of LLSocket::create() in lliosocket.cpp.
@@ -294,7 +279,7 @@ void LLPluginProcessParent::idle(void)
294 APR_INET, 279 APR_INET,
295 0, // port 0 = ephemeral ("find me a port") 280 0, // port 0 = ephemeral ("find me a port")
296 0, 281 0,
297 gAPRPoolp); 282 AIAPRRootPool::get()());
298 283
299 if(ll_apr_warn_status(status)) 284 if(ll_apr_warn_status(status))
300 { 285 {
@@ -617,7 +602,8 @@ void LLPluginProcessParent::setMessagePipe(LLPluginMessagePipe *message_pipe)
617 if(message_pipe != NULL) 602 if(message_pipe != NULL)
618 { 603 {
619 // Set up the apr_pollfd_t 604 // Set up the apr_pollfd_t
620 mPollFD.p = gAPRPoolp; 605
606 mPollFD.p = mPollFDPool();
621 mPollFD.desc_type = APR_POLL_SOCKET; 607 mPollFD.desc_type = APR_POLL_SOCKET;
622 mPollFD.reqevents = APR_POLLIN|APR_POLLERR|APR_POLLHUP; 608 mPollFD.reqevents = APR_POLLIN|APR_POLLERR|APR_POLLHUP;
623 mPollFD.rtnevents = 0; 609 mPollFD.rtnevents = 0;
@@ -664,6 +650,7 @@ void LLPluginProcessParent::updatePollset()
664 // delete the existing pollset. 650 // delete the existing pollset.
665 apr_pollset_destroy(sPollSet); 651 apr_pollset_destroy(sPollSet);
666 sPollSet = NULL; 652 sPollSet = NULL;
653 sPollSetPool.destroy();
667 } 654 }
668 655
669 std::list<LLPluginProcessParent*>::iterator iter; 656 std::list<LLPluginProcessParent*>::iterator iter;
@@ -686,12 +673,14 @@ void LLPluginProcessParent::updatePollset()
686 { 673 {
687#ifdef APR_POLLSET_NOCOPY 674#ifdef APR_POLLSET_NOCOPY
688 // The pollset doesn't exist yet. Create it now. 675 // The pollset doesn't exist yet. Create it now.
689 apr_status_t status = apr_pollset_create(&sPollSet, count, gAPRPoolp, APR_POLLSET_NOCOPY); 676 sPollSetPool.create();
677 apr_status_t status = apr_pollset_create(&sPollSet, count, sPollSetPool(), APR_POLLSET_NOCOPY);
690 if(status != APR_SUCCESS) 678 if(status != APR_SUCCESS)
691 { 679 {
692#endif // APR_POLLSET_NOCOPY 680#endif // APR_POLLSET_NOCOPY
693 LL_WARNS("PluginPoll") << "Couldn't create pollset. Falling back to non-pollset mode." << LL_ENDL; 681 LL_WARNS("PluginPoll") << "Couldn't create pollset. Falling back to non-pollset mode." << LL_ENDL;
694 sPollSet = NULL; 682 sPollSet = NULL;
683 sPollSetPool.destroy();
695#ifdef APR_POLLSET_NOCOPY 684#ifdef APR_POLLSET_NOCOPY
696 } 685 }
697 else 686 else
diff --git a/linden/indra/llplugin/llpluginprocessparent.h b/linden/indra/llplugin/llpluginprocessparent.h
index 95f5f70..bba3643 100755
--- a/linden/indra/llplugin/llpluginprocessparent.h
+++ b/linden/indra/llplugin/llpluginprocessparent.h
@@ -186,7 +186,9 @@ private:
186 186
187 static bool sUseReadThread; 187 static bool sUseReadThread;
188 apr_pollfd_t mPollFD; 188 apr_pollfd_t mPollFD;
189 AIAPRPool mPollFDPool;
189 static apr_pollset_t *sPollSet; 190 static apr_pollset_t *sPollSet;
191 static AIAPRPool sPollSetPool;
190 static bool sPollsetNeedsRebuild; 192 static bool sPollsetNeedsRebuild;
191 static LLMutex *sInstancesMutex; 193 static LLMutex *sInstancesMutex;
192 static std::list<LLPluginProcessParent*> sInstances; 194 static std::list<LLPluginProcessParent*> sInstances;
diff --git a/linden/indra/llplugin/llpluginsharedmemory.cpp b/linden/indra/llplugin/llpluginsharedmemory.cpp
index e8a411a..883d7b6 100755
--- a/linden/indra/llplugin/llpluginsharedmemory.cpp
+++ b/linden/indra/llplugin/llpluginsharedmemory.cpp
@@ -201,7 +201,8 @@ bool LLPluginSharedMemory::create(size_t size)
201 mName += createName(); 201 mName += createName();
202 mSize = size; 202 mSize = size;
203 203
204 apr_status_t status = apr_shm_create( &(mImpl->mAprSharedMemory), mSize, mName.c_str(), gAPRPoolp ); 204 mPool.create();
205 apr_status_t status = apr_shm_create( &(mImpl->mAprSharedMemory), mSize, mName.c_str(), mPool());
205 206
206 if(ll_apr_warn_status(status)) 207 if(ll_apr_warn_status(status))
207 { 208 {
@@ -224,7 +225,7 @@ bool LLPluginSharedMemory::destroy(void)
224 } 225 }
225 mImpl->mAprSharedMemory = NULL; 226 mImpl->mAprSharedMemory = NULL;
226 } 227 }
227 228 mPool.destroy();
228 return true; 229 return true;
229} 230}
230 231
@@ -233,7 +234,8 @@ bool LLPluginSharedMemory::attach(const std::string &name, size_t size)
233 mName = name; 234 mName = name;
234 mSize = size; 235 mSize = size;
235 236
236 apr_status_t status = apr_shm_attach( &(mImpl->mAprSharedMemory), mName.c_str(), gAPRPoolp ); 237 mPool.create();
238 apr_status_t status = apr_shm_attach( &(mImpl->mAprSharedMemory), mName.c_str(), mPool() );
237 239
238 if(ll_apr_warn_status(status)) 240 if(ll_apr_warn_status(status))
239 { 241 {
@@ -255,6 +257,7 @@ bool LLPluginSharedMemory::detach(void)
255 } 257 }
256 mImpl->mAprSharedMemory = NULL; 258 mImpl->mAprSharedMemory = NULL;
257 } 259 }
260 mPool.destroy();
258 261
259 return true; 262 return true;
260} 263}
diff --git a/linden/indra/llplugin/llpluginsharedmemory.h b/linden/indra/llplugin/llpluginsharedmemory.h
index 081d311..669a3e4 100755
--- a/linden/indra/llplugin/llpluginsharedmemory.h
+++ b/linden/indra/llplugin/llpluginsharedmemory.h
@@ -35,6 +35,8 @@
35#ifndef LL_LLPLUGINSHAREDMEMORY_H 35#ifndef LL_LLPLUGINSHAREDMEMORY_H
36#define LL_LLPLUGINSHAREDMEMORY_H 36#define LL_LLPLUGINSHAREDMEMORY_H
37 37
38#include "aiaprpool.h"
39
38class LLPluginSharedMemoryPlatformImpl; 40class LLPluginSharedMemoryPlatformImpl;
39 41
40/** 42/**
@@ -115,6 +117,7 @@ private:
115 bool close(void); 117 bool close(void);
116 bool unlink(void); 118 bool unlink(void);
117 119
120 AIAPRPool mPool;
118 std::string mName; 121 std::string mName;
119 size_t mSize; 122 size_t mSize;
120 void *mMappedAddress; 123 void *mMappedAddress;
diff --git a/linden/indra/llplugin/slplugin/slplugin.cpp b/linden/indra/llplugin/slplugin/slplugin.cpp
index 64c087b..cca8ead 100755
--- a/linden/indra/llplugin/slplugin/slplugin.cpp
+++ b/linden/indra/llplugin/slplugin/slplugin.cpp
@@ -183,8 +183,6 @@ int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdL
183int main(int argc, char **argv) 183int main(int argc, char **argv)
184#endif 184#endif
185{ 185{
186 ll_init_apr();
187
188 // Set up llerror logging 186 // Set up llerror logging
189 { 187 {
190 LLError::initForApplication("."); 188 LLError::initForApplication(".");
@@ -400,8 +398,6 @@ int main(int argc, char **argv)
400 398
401 delete plugin; 399 delete plugin;
402 400
403 ll_cleanup_apr();
404
405 return 0; 401 return 0;
406} 402}
407 403