summaryrefslogtreecommitdiff
path: root/indra/llplugin/llpluginmessagepipe.cpp
diff options
context:
space:
mode:
authorMonroe Linden <monroe@lindenlab.com>2010-04-29 17:33:37 -0700
committerMonroe Linden <monroe@lindenlab.com>2010-04-29 17:33:37 -0700
commit77b13dc2df679c46f648a4f99c8e4d8836983a48 (patch)
treeebdf680fb2be21edb02d9f5ef5e4133cf307236d /indra/llplugin/llpluginmessagepipe.cpp
parentdacc5afbf0f1bde7454c1eadf56edb669d0741a9 (diff)
Incorporate suggestions from Richard's review of the LLPlugin changes.
Use LLMutexLock (stack-based locker/unlocker) for the straightforward cases instead of explicit lock()/unlock(). There are still a couple of cases (one overlapping lock lifetime and two loops that unlock the mutex to call another function inside the loop) where I'm leaving explicit lock/unlock calls. Rename LLPluginProcessParent::sPollThread to sReadThread, for consistency. Made the LLPluginProcessParent destructor hold mIncomingQueueMutex while removing the instance from the global list -- this should prevent a possible race condition in LLPluginProcessParent::poll(). Removed a redundant check when calling LLPluginProcessParent::setUseReadThread().
Diffstat (limited to 'indra/llplugin/llpluginmessagepipe.cpp')
-rw-r--r--indra/llplugin/llpluginmessagepipe.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/indra/llplugin/llpluginmessagepipe.cpp b/indra/llplugin/llpluginmessagepipe.cpp
index a62534de95..89f8b44569 100644
--- a/indra/llplugin/llpluginmessagepipe.cpp
+++ b/indra/llplugin/llpluginmessagepipe.cpp
@@ -117,10 +117,9 @@ LLPluginMessagePipe::~LLPluginMessagePipe()
bool LLPluginMessagePipe::addMessage(const std::string &message)
{
// queue the message for later output
- mOutputMutex.lock();
+ LLMutexLock lock(&mOutputMutex);
mOutput += message;
mOutput += MESSAGE_DELIMITER; // message separator
- mOutputMutex.unlock();
return true;
}
@@ -173,7 +172,7 @@ bool LLPluginMessagePipe::pumpOutput()
apr_status_t status;
apr_size_t size;
- mOutputMutex.lock();
+ LLMutexLock lock(&mOutputMutex);
if(!mOutput.empty())
{
// write any outgoing messages
@@ -225,7 +224,6 @@ bool LLPluginMessagePipe::pumpOutput()
result = false;
}
}
- mOutputMutex.unlock();
}
return result;
@@ -288,9 +286,8 @@ bool LLPluginMessagePipe::pumpInput(F64 timeout)
if(size > 0)
{
- mInputMutex.lock();
+ LLMutexLock lock(&mInputMutex);
mInput.append(input_buf, size);
- mInputMutex.unlock();
}
if(status == APR_SUCCESS)