diff --git a/direct/src/plugin/p3dFileParams.cxx b/direct/src/plugin/p3dFileParams.cxx index af7de5fdc2..e5cdbb235e 100644 --- a/direct/src/plugin/p3dFileParams.cxx +++ b/direct/src/plugin/p3dFileParams.cxx @@ -32,7 +32,8 @@ P3DFileParams() { P3DFileParams:: P3DFileParams(const P3DFileParams ©) : _p3d_filename(copy._p3d_filename), - _tokens(copy._tokens) + _tokens(copy._tokens), + _args(copy._args) { } @@ -45,6 +46,7 @@ void P3DFileParams:: operator = (const P3DFileParams &other) { _p3d_filename = other._p3d_filename; _tokens = other._tokens; + _args = other._args; } //////////////////////////////////////////////////////////////////// diff --git a/direct/src/plugin/p3dInstance.cxx b/direct/src/plugin/p3dInstance.cxx index bc90ad46ca..dd9a2cf086 100644 --- a/direct/src/plugin/p3dInstance.cxx +++ b/direct/src/plugin/p3dInstance.cxx @@ -63,6 +63,7 @@ P3DInstance(P3D_request_ready_func *func, _got_wparams = false; _fparams.set_tokens(tokens, num_tokens); + _fparams.set_args(argc, argv); P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); _instance_id = inst_mgr->get_unique_id(); diff --git a/direct/src/plugin/p3dPackage.cxx b/direct/src/plugin/p3dPackage.cxx index 984558471d..4ae7faba96 100755 --- a/direct/src/plugin/p3dPackage.cxx +++ b/direct/src/plugin/p3dPackage.cxx @@ -345,6 +345,8 @@ got_desc_file(TiXmlDocument *doc, bool freshly_downloaded) { if (all_extracts_ok) { // Great, we're ready to begin. + nout << "All " << _extracts.size() << " extracts of " << _package_name + << " seem good.\n"; report_done(true); } else { diff --git a/direct/src/plugin/p3dSession.cxx b/direct/src/plugin/p3dSession.cxx index 3f45d962d0..bddecfc64e 100644 --- a/direct/src/plugin/p3dSession.cxx +++ b/direct/src/plugin/p3dSession.cxx @@ -53,6 +53,7 @@ P3DSession(P3DInstance *inst) { _python_version = inst->get_python_version(); _start_dir = inst_mgr->get_root_dir() + "/start"; + _p3dpython_started = false; _p3dpython_running = false; _started_read_thread = false; @@ -82,7 +83,7 @@ P3DSession:: //////////////////////////////////////////////////////////////////// void P3DSession:: shutdown() { - if (_p3dpython_running) { + if (_p3dpython_started) { // Tell the process we're going away. TiXmlDocument doc; TiXmlElement *xcommand = new TiXmlElement("command"); @@ -159,6 +160,7 @@ shutdown() { #endif // _WIN32 _p3dpython_running = false; + _p3dpython_started = false; } // If there are any leftover commands in the queue (presumably @@ -258,7 +260,7 @@ terminate_instance(P3DInstance *inst) { //////////////////////////////////////////////////////////////////// void P3DSession:: send_command(TiXmlDocument *command) { - if (_p3dpython_running) { + if (_p3dpython_started) { // Python is running. Send the command. write_xml(_pipe_write, command, nout); delete command; @@ -285,7 +287,7 @@ send_command(TiXmlDocument *command) { //////////////////////////////////////////////////////////////////// TiXmlDocument *P3DSession:: command_and_response(TiXmlDocument *command) { - if (!_p3dpython_running) { + if (!_p3dpython_started) { return NULL; } @@ -307,9 +309,6 @@ command_and_response(TiXmlDocument *command) { while (ri == _responses.end()) { if (!_p3dpython_running) { // Hmm, looks like Python has gone away. - - // TODO: make sure _p3dpython_running gets set to false when the - // process dies unexpectedly. _response_ready.release(); return NULL; } @@ -593,7 +592,7 @@ signal_request_ready(P3DInstance *inst) { //////////////////////////////////////////////////////////////////// void P3DSession:: drop_pyobj(int object_id) { - if (_p3dpython_running) { + if (_p3dpython_started) { TiXmlDocument doc; TiXmlElement *xcommand = new TiXmlElement("command"); xcommand->SetAttribute("cmd", "drop_pyobj"); @@ -641,7 +640,7 @@ report_packages_done(P3DInstance *inst, bool success) { //////////////////////////////////////////////////////////////////// void P3DSession:: start_p3dpython(P3DInstance *inst) { - if (_p3dpython_running) { + if (_p3dpython_started) { // Already started. return; } @@ -805,6 +804,7 @@ start_p3dpython(P3DInstance *inst) { nout << "Failed to create process.\n"; return; } + _p3dpython_started = true; _p3dpython_running = true; if (!_pipe_read) { @@ -880,6 +880,10 @@ rt_thread_run() { if (doc == NULL) { // Some error on reading. Abort. rt_terminate(); + _p3dpython_running = false; + _response_ready.acquire(); + _response_ready.notify(); + _response_ready.release(); return; } diff --git a/direct/src/plugin/p3dSession.h b/direct/src/plugin/p3dSession.h index 7dc4017b74..250628a8c4 100644 --- a/direct/src/plugin/p3dSession.h +++ b/direct/src/plugin/p3dSession.h @@ -118,6 +118,7 @@ private: #else int _p3dpython_pid; #endif + bool _p3dpython_started; bool _p3dpython_running; // The _response_ready mutex protects this structure.