[rkward-cvs] SF.net SVN: rkward:[2649] trunk/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Fri Sep 18 10:52:41 UTC 2009


Revision: 2649
          http://rkward.svn.sourceforge.net/rkward/?rev=2649&view=rev
Author:   tfry
Date:     2009-09-18 10:52:41 +0000 (Fri, 18 Sep 2009)

Log Message:
-----------
Mutex must not be locked while calling processX11Events. Substacks may be called from inside.
This fixes a deadlock while handling tcl events, but more testing is needed.
See https://sourceforge.net/tracker/?func=detail&atid=459007&aid=2861059&group_id=50231

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/rkward/rbackend/rthread.cpp

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2009-09-15 11:09:19 UTC (rev 2648)
+++ trunk/rkward/ChangeLog	2009-09-18 10:52:41 UTC (rev 2649)
@@ -1,3 +1,4 @@
+- Fix deadlock while handling some tcl events		TODO: much more (stress-)testing, backport? (r2649)
 - Plugin dialogs close automatically after submitting (by default)
 - Fetching object structure is much faster for very large data.frames
 - Fix crash when loading certain packages on Windows
@@ -5,7 +6,7 @@
 - "Analysis" menu was restructured, slightly
 - Debug output (previously sent to stderr) is now written to a temporary file
 - On plugin help pages, display a link to invoke the plugin
-- Tolerate missing libraries in testing framework	TODO: - Encourage running 'make plugintests' after install in all relevant places
+- Tolerate missing libraries in testing framework
 - Double-clicking an item in the workspace browser now opens an object viewer, or (if possible) editor
 - Safeguard against removal of essential packages via the GUI
 - Add context menu action to unload packages in the workspace browser window

Modified: trunk/rkward/rkward/rbackend/rthread.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rthread.cpp	2009-09-15 11:09:19 UTC (rev 2648)
+++ trunk/rkward/rkward/rbackend/rthread.cpp	2009-09-18 10:52:41 UTC (rev 2649)
@@ -106,9 +106,9 @@
 	MUTEX_UNLOCK;
 
 	while (1) {
-		MUTEX_LOCK;
 		processX11Events ();
 
+		MUTEX_LOCK;
 		if (previously_idle) {
 			if (!RCommandStack::regular_stack->isEmpty ()) {
 				qApp->postEvent (RKGlobals::rInterface (), new RKRBackendEvent (RKRBackendEvent::RBusy));
@@ -124,7 +124,6 @@
 				// mutex will be unlocked inside
 				doCommand (current_command);
 				checkObjectUpdatesNeeded (current_command->type () & (RCommand::User | RCommand::ObjectListUpdate));
-				processX11Events ();
 				RCommandStack::regular_stack->pop ();
 				notifyCommandDone (current_command);	// command may be deleted after this
 			}
@@ -189,6 +188,7 @@
 		} else {
 			runCommandInternal (ccommand, &error, ctype & RCommand::User);
 		}
+		if (!locked || killed) processX11Events ();
 		MUTEX_LOCK;
 
 		#ifdef RKWARD_DEBUG
@@ -434,8 +434,8 @@
 	
 	bool done = false;
 	while (!done) {
-		MUTEX_LOCK;
 		processX11Events ();
+		MUTEX_LOCK;
 		// while commands are in queue, don't wait
 		while (reply_stack->isActive ()) {		// substack calls are to be considered "sync", and don't respect locks
 			if (killed) {
@@ -448,8 +448,6 @@
 				// mutex will be unlocked inside
 				bool object_update_forced = (current_command->type () & RCommand::ObjectListUpdate);
 				doCommand (current_command);
-				if (!(locked || killed)) processX11Events ();
-				else msleep (100);
 				if (object_update_forced) checkObjectUpdatesNeeded (true);
 				reply_stack->pop ();
 				notifyCommandDone (current_command);	// command may be deleted after this
@@ -488,11 +486,7 @@
 	while (!(*done)) {
 		msleep (10); // callback not done yet? Sleep for a while
 
-		if (!(locked || killed)) {			// what's with that lock? If the current command is cancelled, while we're in this loop, we must not lock the mutex and/or call anything in R. We may get long-jumped out of the loop before we get a chance to unlock
-			MUTEX_LOCK;
-			if (!(locked || killed)) processX11Events ();
-			MUTEX_UNLOCK;
-		}
+		if (!(locked || killed)) processX11Events ();
 	}
 
 	RK_DO (qDebug ("standard callback done"), RBACKEND, DL_DEBUG);


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