From 499fbe058550a9ee1ec2aae151af22e897abbc27 Mon Sep 17 00:00:00 2001
From: David <david.schiebener@kit.edu>
Date: Tue, 19 Jan 2016 19:29:35 +0100
Subject: [PATCH] lock now locks everything so there are no more segfaults (I
 hope)

---
 .../components/units/TCPControlUnit.cpp       | 30 +++++++++----------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/source/RobotAPI/components/units/TCPControlUnit.cpp b/source/RobotAPI/components/units/TCPControlUnit.cpp
index c9279c4ed..ccc88e992 100644
--- a/source/RobotAPI/components/units/TCPControlUnit.cpp
+++ b/source/RobotAPI/components/units/TCPControlUnit.cpp
@@ -306,9 +306,9 @@ namespace armarx
     {
         ScopedTryLock lock(dataMutex);
 
+        if (lock.owns_lock())
         {
 
-            if (lock.owns_lock())
             {
                 localTcpVelocitiesMap.clear();
                 TCPVelocityDataMap::iterator it = tcpVelocitiesMap.begin();
@@ -331,23 +331,23 @@ namespace armarx
                 RemoteRobot::synchronizeLocalClone(localRobot, robotStateComponentPrx);
                 //ARMARX_DEBUG << "RN TCP R pose2:" << localRobot->getRobotNode("TCP R")->getGlobalPose();
             }
-        }
 
-        calculationRunning = true;
+            //calculationRunning = true;
 
-        if (requested)
-        {
-            //            if((IceUtil::Time::now()-lastCommandTime).toMilliSecondsDouble() > getProperty<float>("MaximumCommandDelay").getValue())
-            //            {
-            //                ARMARX_WARNING << "Exceeded MaximumCommandDelay - releasing TCPControlUnit";
-            //                calculationRunning = false;
-            //                release();                          <---- this is a potential deadlock
-            //            }
-            //            else
-            calcAndSetVelocities();
-        }
+            if (requested)
+            {
+                //            if((IceUtil::Time::now()-lastCommandTime).toMilliSecondsDouble() > getProperty<float>("MaximumCommandDelay").getValue())
+                //            {
+                //                ARMARX_WARNING << "Exceeded MaximumCommandDelay - releasing TCPControlUnit";
+                //                calculationRunning = false;
+                //                release();                          <---- this is a potential deadlock
+                //            }
+                //            else
+                calcAndSetVelocities();
+            }
 
-        calculationRunning = false;
+            //calculationRunning = false;
+        }
     }
 
 
-- 
GitLab