[rkward-cvs] SF.net SVN: rkward:[2763] branches/release_branch_0.4.9/rkward/rbackend/ rthread.cpp

tfry at users.sourceforge.net tfry at users.sourceforge.net
Sat Mar 6 11:43:48 UTC 2010


Revision: 2763
          http://rkward.svn.sourceforge.net/rkward/?rev=2763&view=rev
Author:   tfry
Date:     2010-03-06 11:43:48 +0000 (Sat, 06 Mar 2010)

Log Message:
-----------
Merge 2649 from trunk (fix deadlock while handling some tcl events)

Modified Paths:
--------------
    branches/release_branch_0.4.9/rkward/rbackend/rthread.cpp

Modified: branches/release_branch_0.4.9/rkward/rbackend/rthread.cpp
===================================================================
--- branches/release_branch_0.4.9/rkward/rbackend/rthread.cpp	2010-03-04 12:57:05 UTC (rev 2762)
+++ branches/release_branch_0.4.9/rkward/rbackend/rthread.cpp	2010-03-06 11:43:48 UTC (rev 2763)
@@ -2,7 +2,7 @@
                           rthread  -  description
                              -------------------
     begin                : Mon Aug 2 2004
-    copyright            : (C) 2004, 2006, 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2006, 2007, 2010 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -91,9 +91,9 @@
 	MUTEX_UNLOCK;
 	
 	while (1) {
-		MUTEX_LOCK;
 		processX11Events ();
 
+		MUTEX_LOCK;
 		if (previously_idle) {
 			if (!RCommandStack::regular_stack->isEmpty ()) {
 				qApp->postEvent (RKGlobals::rInterface (), new QCustomEvent (RBUSY_EVENT));
@@ -111,7 +111,6 @@
 				// mutex will be unlocked inside
 				doCommand (command);
 				checkObjectUpdatesNeeded (check_list);
-				processX11Events ();
 			}
 		
 			if (killed) {
@@ -179,6 +178,7 @@
 		} else {
 			runCommandInternal (ccommand, &error, ctype & RCommand::User);
 		}
+		if (!locked || killed) processX11Events ();
 
 		MUTEX_LOCK;
 
@@ -388,8 +388,8 @@
 	
 	bool done = false;
 	while (!done) {
-		MUTEX_LOCK;
 		processX11Events ();
+		MUTEX_LOCK;
 		// while commands are in queue, don't wait
 		while (reply_stack->isActive () && !locked) {
 			if (killed) {
@@ -404,7 +404,6 @@
 				bool object_update_forced = (command->type () & RCommand::ObjectListUpdate);
 				doCommand (command);
 				if (object_update_forced) checkObjectUpdatesNeeded (true);
-				processX11Events ();
 			}
 		}
 
@@ -437,11 +436,7 @@
 	while (!(*done)) {
 		msleep (10); // callback not done yet? Sleep for a while
 
-		if (!locked) {			// 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) 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