[rkward-cvs] SF.net SVN: rkward:[3134] branches/2010_10_18_backend_restructuring_branch/ rkward/rbackend
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Tue Oct 19 11:58:15 UTC 2010
Revision: 3134
http://rkward.svn.sourceforge.net/rkward/?rev=3134&view=rev
Author: tfry
Date: 2010-10-19 11:58:15 +0000 (Tue, 19 Oct 2010)
Log Message:
-----------
Fix mutex for 'direct' commands
Modified Paths:
--------------
branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rembedinternal.cpp
branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rinterface.h
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-19 10:57:27 UTC (rev 3133)
+++ branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rembedinternal.cpp 2010-10-19 11:58:15 UTC (rev 3134)
@@ -1042,7 +1042,9 @@
QByteArray ccommand = current_locale_codec->fromUnicode (command->command ());
RData retdata;
- MUTEX_UNLOCK;
+ if (!(ctype & RCommand::Internal)) {
+ MUTEX_UNLOCK;
+ }
// running user commands is quite different from all other commands
if (ctype & RCommand::User) {
// run a user command
@@ -1105,13 +1107,13 @@
if (error == NoError) {
if (ctype & RCommand::GetStringVector) {
retdata.datatype = RData::StringVector;
- retdata.data = SEXPToStringList (exp, &(command->length));
+ retdata.data = SEXPToStringList (exp, &(retdata.length));
} else if (ctype & RCommand::GetRealVector) {
retdata.datatype = RData::RealVector;
- retdata.data = SEXPToRealArray (exp, &(command->length));
+ retdata.data = SEXPToRealArray (exp, &(retdata.length));
} else if (ctype & RCommand::GetIntVector) {
retdata.datatype = RData::IntVector;
- retdata.data = SEXPToIntArray (exp, &(command->length));
+ retdata.data = SEXPToIntArray (exp, &(retdata.length));
} else if (ctype & RCommand::GetStructuredData) {
RData *dummy = SEXPToRData (exp);
retdata.setData (*dummy);
@@ -1121,8 +1123,10 @@
UNPROTECT (1); // exp
}
}
- if (!locked || killed) processX11Events ();
- MUTEX_LOCK;
+ if (!(ctype & RCommand::Internal)) {
+ if (!locked || killed) processX11Events ();
+ MUTEX_LOCK;
+ }
command->setData (retdata);
// common error/status handling
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-19 10:57:27 UTC (rev 3133)
+++ branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rinterface.h 2010-10-19 11:58:15 UTC (rev 3134)
@@ -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/rthread.cpp
===================================================================
--- branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rthread.cpp 2010-10-19 10:57:27 UTC (rev 3133)
+++ branches/2010_10_18_backend_restructuring_branch/rkward/rbackend/rthread.cpp 2010-10-19 11:58:15 UTC (rev 3134)
@@ -215,6 +215,7 @@
if (!buf_length) return;
waitIfOutputPaused ();
+ MUTEX_LOCK;
ROutput::ROutputType output_type;
if (regular) {
output_type = ROutput::Output;
@@ -234,17 +235,18 @@
}
current_output->output.append (output);
+
if ((out_buf_len += buf_length) > MAX_BUF_LENGTH) {
RK_DO (qDebug ("Output buffer has %d characters. Forcing flush", out_buf_len), RBACKEND, DL_DEBUG);
flushOutput ();
}
+ MUTEX_UNLOCK;
}
void RThread::flushOutput () {
if (!current_output) return; // avoid creating loads of traces
RK_TRACE (RBACKEND);
- MUTEX_LOCK;
if (current_command) {
for (QList<RCommand*>::const_iterator it = all_current_commands.constBegin (); it != all_current_commands.constEnd(); ++it) {
ROutput *output = current_output;
@@ -277,7 +279,6 @@
RK_DO (qDebug ("output without receiver'%s'", current_output->output.toLatin1 ().data ()), RBACKEND, DL_WARNING);
delete current_output;
}
- MUTEX_UNLOCK;
// forget output
current_output = 0;
@@ -373,7 +374,9 @@
void RThread::handleStandardCallback (RCallbackArgs *args) {
RK_TRACE (RBACKEND);
+ MUTEX_LOCK;
flushOutput ();
+ MUTEX_UNLOCK;
args->done = false;
RKRBackendEvent* event = new RKRBackendEvent (RKRBackendEvent::RCallbackRequest, args);
@@ -437,7 +440,9 @@
if (!runDirectCommand ("options (error=quote (.rk.do.error ()))\n")) status |= SinkFail;
if (!runDirectCommand ("rk.set.output.html.file (\"" + RKSettingsModuleGeneral::filesPath () + "/rk_out.html\")\n")) status |= SinkFail;
+ MUTEX_LOCK;
flushOutput ();
+ MUTEX_UNLOCK;
return status;
}
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