diff options
Diffstat (limited to 'indra/llplugin/llpluginprocessparent.cpp')
-rwxr-xr-x[-rw-r--r--] | indra/llplugin/llpluginprocessparent.cpp | 63 |
1 files changed, 35 insertions, 28 deletions
diff --git a/indra/llplugin/llpluginprocessparent.cpp b/indra/llplugin/llpluginprocessparent.cpp index c002de0462..b5a2588e1e 100644..100755 --- a/indra/llplugin/llpluginprocessparent.cpp +++ b/indra/llplugin/llpluginprocessparent.cpp @@ -31,6 +31,8 @@ #include "llpluginprocessparent.h" #include "llpluginmessagepipe.h" #include "llpluginmessageclasses.h" +#include "llsdserialize.h" +#include "stringize.h" #include "llapr.h" @@ -129,12 +131,14 @@ LLPluginProcessParent::~LLPluginProcessParent() { // destroy the shared memory region iter->second->destroy(); + delete iter->second; + iter->second = NULL; // and remove it from our map mSharedMemoryRegions.erase(iter); } - - mProcess.kill(); + + LLProcess::kill(mProcess); killSockets(); } @@ -157,10 +161,12 @@ void LLPluginProcessParent::errorState(void) setState(STATE_ERROR); } -void LLPluginProcessParent::init(const std::string &launcher_filename, const std::string &plugin_filename, bool debug) +void LLPluginProcessParent::init(const std::string &launcher_filename, const std::string &plugin_dir, const std::string &plugin_filename, bool debug) { - mProcess.setExecutable(launcher_filename); + mProcessParams.executable = launcher_filename; + mProcessParams.cwd = plugin_dir; mPluginFile = plugin_filename; + mPluginDir = plugin_dir; mCPUUsage = 0.0f; mDebug = debug; setState(STATE_INITIALIZED); @@ -181,7 +187,7 @@ bool LLPluginProcessParent::accept() if(status == APR_SUCCESS) { -// llinfos << "SUCCESS" << llendl; +// LL_INFOS() << "SUCCESS" << LL_ENDL; // 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! @@ -195,14 +201,14 @@ bool LLPluginProcessParent::accept() } else if(APR_STATUS_IS_EAGAIN(status)) { -// llinfos << "EAGAIN" << llendl; +// LL_INFOS() << "EAGAIN" << LL_ENDL; // No incoming connections. This is not an error. status = APR_SUCCESS; } else { -// llinfos << "Error:" << llendl; +// LL_INFOS() << "Error:" << LL_ENDL; ll_apr_warn_status(status); // Some other error. @@ -369,10 +375,8 @@ void LLPluginProcessParent::idle(void) // Launch the plugin process. // Only argument to the launcher is the port number we're listening on - std::stringstream stream; - stream << mBoundPort; - mProcess.addArgument(stream.str()); - if(mProcess.launch() != 0) + mProcessParams.args.add(stringize(mBoundPort)); + if (! (mProcess = LLProcess::create(mProcessParams))) { errorState(); } @@ -386,19 +390,18 @@ void LLPluginProcessParent::idle(void) // The command we're constructing would look like this on the command line: // osascript -e 'tell application "Terminal"' -e 'set win to do script "gdb -pid 12345"' -e 'do script "continue" in win' -e 'end tell' - std::stringstream cmd; - - mDebugger.setExecutable("/usr/bin/osascript"); - mDebugger.addArgument("-e"); - mDebugger.addArgument("tell application \"Terminal\""); - mDebugger.addArgument("-e"); - cmd << "set win to do script \"gdb -pid " << mProcess.getProcessID() << "\""; - mDebugger.addArgument(cmd.str()); - mDebugger.addArgument("-e"); - mDebugger.addArgument("do script \"continue\" in win"); - mDebugger.addArgument("-e"); - mDebugger.addArgument("end tell"); - mDebugger.launch(); + LLProcess::Params params; + params.executable = "/usr/bin/osascript"; + params.args.add("-e"); + params.args.add("tell application \"Terminal\""); + params.args.add("-e"); + params.args.add(STRINGIZE("set win to do script \"gdb -pid " + << mProcess->getProcessID() << "\"")); + params.args.add("-e"); + params.args.add("do script \"continue\" in win"); + params.args.add("-e"); + params.args.add("end tell"); + mDebugger = LLProcess::create(params); #endif } @@ -445,6 +448,7 @@ void LLPluginProcessParent::idle(void) { LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_INTERNAL, "load_plugin"); message.setValue("file", mPluginFile); + message.setValue("dir", mPluginDir); sendMessage(message); } @@ -467,7 +471,7 @@ void LLPluginProcessParent::idle(void) break; case STATE_EXITING: - if(!mProcess.isRunning()) + if (! LLProcess::isRunning(mProcess)) { setState(STATE_CLEANUP); } @@ -495,7 +499,7 @@ void LLPluginProcessParent::idle(void) break; case STATE_CLEANUP: - mProcess.kill(); + LLProcess::kill(mProcess); killSockets(); setState(STATE_DONE); break; @@ -835,7 +839,7 @@ void LLPluginProcessParent::receiveMessageRaw(const std::string &message) LL_DEBUGS("Plugin") << "Received: " << message << LL_ENDL; LLPluginMessage parsed; - if(parsed.parse(message) != -1) + if(LLSDParser::PARSE_FAILURE != parsed.parse(message)) { if(parsed.hasValue("blocking_request")) { @@ -924,6 +928,7 @@ void LLPluginProcessParent::receiveMessage(const LLPluginMessage &message) } // Send initial sleep time + llassert_always(mSleepTime != 0.f); setSleepTime(mSleepTime, true); setState(STATE_RUNNING); @@ -957,6 +962,8 @@ void LLPluginProcessParent::receiveMessage(const LLPluginMessage &message) { // destroy the shared memory region iter->second->destroy(); + delete iter->second; + iter->second = NULL; // and remove it from our map mSharedMemoryRegions.erase(iter); @@ -1073,7 +1080,7 @@ bool LLPluginProcessParent::pluginLockedUpOrQuit() { bool result = false; - if(!mProcess.isRunning()) + if (! LLProcess::isRunning(mProcess)) { LL_WARNS("Plugin") << "child exited" << LL_ENDL; result = true; |