[rkward-cvs] SF.net SVN: rkward:[3146] branches/2010_10_18_backend_restructuring_branch/ rkward/rbackend
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Mon Oct 25 16:28:20 UTC 2010
Revision: 3146
http://rkward.svn.sourceforge.net/rkward/?rev=3146&view=rev
Author: tfry
Date: 2010-10-25 16:28:20 +0000 (Mon, 25 Oct 2010)
Log Message:
-----------
Fix hang on exit
Modified Paths:
--------------
branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rembedinternal.cpp
branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rembedinternal.h
branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rinterface.h
branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rkrsupport.cpp
branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rthread.cpp
Modified: branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rembedinternal.cpp
===================================================================
--- branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rembedinternal.cpp 2010-10-25 15:11:54 UTC (rev 3145)
+++ branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rembedinternal.cpp 2010-10-25 16:28:20 UTC (rev 3146)
@@ -122,8 +122,7 @@
args.type = RCallbackArgs::RBackendExit;
args.params["message"] = QVariant (i18n ("The R engine has encountered a fatal error:\n%1").arg (message));
RThread::this_pointer->handleStandardCallback (&args);
- RThread::this_pointer->shutdown (true);
- Rf_error ("Backend dead"); // this jumps us out of the REPL.
+ RThread::this_pointer->killed = true;
}
Rboolean RKToplevelStatementFinishedCallback (SEXP expr, SEXP value, Rboolean succeeded, Rboolean visible, void *) {
@@ -193,6 +192,8 @@
RK_ASSERT (RThread::repl_status.eval_depth >= 0);
if (RThread::repl_status.eval_depth == 0) {
while (1) {
+ if (RThread::this_pointer->killed) return 0;
+
if (RThread::repl_status.user_command_status == RThread::RKReplStatus::NoUserCommand) {
RCommand *command = RThread::this_pointer->fetchNextCommand (RCommandStack::regular_stack);
if (!command) {
@@ -350,11 +351,8 @@
} else {
if (RunLast) R_dot_Last ();
}
-
- RThread::this_pointer->shutdown (false);
- } else {
- RThread::this_pointer->shutdown (true);
}
+ RThread::this_pointer->killed = true;
Rf_error ("Backend dead"); // this jumps us out of the REPL.
}
@@ -631,15 +629,6 @@
RK_TRACE (RBACKEND);
}
-void RThread::shutdown (bool suicidal) {
- RK_TRACE (RBACKEND);
-
- if (!r_running) return; // already shut down
- r_running = false;
-
- Rf_endEmbeddedR (suicidal);
-}
-
#if 0
static int timeout_counter = 0;
#endif
@@ -1031,6 +1020,7 @@
RK_TRACE (RBACKEND);
run_Rmainloop ();
+ Rf_endEmbeddedR (0);
}
SEXP parseCommand (const QString &command_qstring, RThread::RKWardRError *error) {
Modified: branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rembedinternal.h
===================================================================
--- branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rembedinternal.h 2010-10-25 15:11:54 UTC (rev 3145)
+++ branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rembedinternal.h 2010-10-25 16:28:20 UTC (rev 3146)
@@ -160,10 +160,6 @@
int initialize ();
void enterEventLoop ();
-
-/** clean shutdown of R.
- at param suicidal if true, perform only the most basic shutdown operations */
- void shutdown (bool suicidal);
protected:
/** low-level initialization of R
@param argc Number of arguments as would be passed on the commandline to R
@@ -272,11 +268,11 @@
// fetch next command (and do event processing while waiting)
RCommand *fetchNextCommand (RCommandStack *stack);
void commandFinished (bool check_object_updates_needed=true);
+/** thread is killed. Should exit as soon as possible. @see kill */
+ bool killed;
protected:
/** thread is locked. No new commands will be executed. @see LockType @see lock @see unlock */
int locked;
-/** thread is killed. Should exit as soon as possible. @see kill */
- bool killed;
bool previously_idle;
/** On pthread systems this is the pthread_id of the backend thread. It is needed to send SIGINT to the R backend */
Qt::HANDLE thread_id;
Modified: branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rinterface.h
===================================================================
--- branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rinterface.h 2010-10-25 15:11:54 UTC (rev 3145)
+++ branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rinterface.h 2010-10-25 16:28:20 UTC (rev 3146)
@@ -24,7 +24,7 @@
#include "rcommand.h"
-#define DEBUG_MUTEX
+//#define DEBUG_MUTEX
#ifdef DEBUG_MUTEX
#define MUTEX_LOCK RInterface::mutex.lock (); qDebug ("mutex locks: %d, locked in %s, %s, %d", ++RInterface::mutex_counter, __FILE__, __FUNCTION__, __LINE__);
#define MUTEX_UNLOCK qDebug ("mutex locks: %d, unlocked in %s, %s, %d", --RInterface::mutex_counter, __FILE__, __FUNCTION__, __LINE__); RInterface::mutex.unlock ();
Modified: branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rkrsupport.cpp
===================================================================
--- branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rkrsupport.cpp 2010-10-25 15:11:54 UTC (rev 3145)
+++ branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rkrsupport.cpp 2010-10-25 16:28:20 UTC (rev 3146)
@@ -17,8 +17,6 @@
#include "rkrsupport.h"
-#include <QString>
-
#include "../debug.h"
SEXP RKRSupport::callSimpleFun0 (SEXP fun, SEXP env) {
Modified: branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rthread.cpp
===================================================================
--- branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rthread.cpp 2010-10-25 15:11:54 UTC (rev 3145)
+++ branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rthread.cpp 2010-10-25 16:28:20 UTC (rev 3146)
@@ -139,9 +139,6 @@
command->status |= RCommand::Failed;
} else if (command->type () & RCommand::QuitCommand) {
killed = true;
- MUTEX_UNLOCK;
- shutdown (false);
- MUTEX_LOCK; // I guess we don't get here, though?
}
commandFinished ();
} else {
@@ -171,7 +168,6 @@
// if no commands are in queue, sleep for a while
MUTEX_UNLOCK;
if (killed) {
- shutdown (false);
return 0;
}
msleep (10);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list