Skip to content
Snippets Groups Projects
Commit fcede046 authored by Nikolaus Vahrenkamp's avatar Nikolaus Vahrenkamp
Browse files

Added mutex to avoid crash on concurrent robot cloning

parent 384dc97d
No related branches found
No related tags found
No related merge requests found
......@@ -236,6 +236,8 @@ SharedRobotServant::~SharedRobotServant()
#ifdef VERBOSE
ARMARX_WARNING_S << "destruct " << this << flush;
#endif
boost::recursive_mutex::scoped_lock cloneLock(m);
BOOST_FOREACH(NodeCache::value_type value, this->_cachedNodes)
value.second->unref();
}
......@@ -244,6 +246,7 @@ SharedRobotNodeInterfacePrx SharedRobotServant::getRobotNode(const string &name,
{
// ARMARX_LOG_S << "Looking for node: " << name << flush;
assert(_robot);
boost::recursive_mutex::scoped_lock cloneLock(m);
if (this->_cachedNodes.find(name) == this->_cachedNodes.end()){
RobotNodePtr robotNode = _robot->getRobotNode(name);
......@@ -264,6 +267,7 @@ SharedRobotNodeInterfacePrx SharedRobotServant::getRobotNode(const string &name,
SharedRobotNodeInterfacePrx SharedRobotServant::getRootNode(const Current &current)
{
assert(_robot);
boost::recursive_mutex::scoped_lock cloneLock(m);
string name = _robot->getRootNode()/*,current*/->getName();
return this->getRobotNode(name, current);
}
......
......@@ -118,6 +118,7 @@ namespace armarx {
protected:
VirtualRobot::RobotPtr _robot;
boost::recursive_mutex m;
std::map<std::string, SharedRobotNodeInterfacePrx> _cachedNodes;
};
}
......
......@@ -63,7 +63,7 @@ bool RemoteRobot::hasRobotNode( RobotNodePtr robotNode )
return this->hasRobotNode(robotNode->getName());
/*
* This just does nost work. because you cannot tell wheter RemoteRobotNode<RobotNodeRevolute> or another type is used
* This just does not work. because you cannot tell wheter RemoteRobotNode<RobotNodeRevolute> or another type is used
* perhaps you can infer the actual RobotNodeType somehow. Until now we just check for names which is
* much faster!
*
......@@ -255,6 +255,7 @@ VirtualRobot::RobotNodePtr RemoteRobot::createLocalNode(SharedRobotNodeInterface
VirtualRobot::RobotPtr RemoteRobot::createLocalClone()
{
//ARMARX_IMPORTANT_S << "RemoteRobot local clone" << flush;
boost::recursive_mutex::scoped_lock cloneLock(m);
std::string robotType = getName();
std::string robotName = getName();
......@@ -263,7 +264,6 @@ VirtualRobot::RobotPtr RemoteRobot::createLocalClone()
//RobotNodePtr
SharedRobotNodeInterfacePrx root = _robot->getRootNode();
std::vector<VirtualRobot::RobotNodePtr> allNodes;
std::map< VirtualRobot::RobotNodePtr, std::vector<std::string> > childrenMap;
......@@ -276,13 +276,14 @@ VirtualRobot::RobotPtr RemoteRobot::createLocalClone()
return VirtualRobot::RobotPtr();
}
// clone rns
// clone rns
std::vector<std::string> rns = _robot->getRobotNodeSets();
for (size_t i=0;i<rns.size();i++)
{
RobotNodeSetInfoPtr rnsInfo = _robot->getRobotNodeSet(rns[i]);
RobotNodeSet::createRobotNodeSet(robo,rnsInfo->name,rnsInfo->names,rnsInfo->rootName,rnsInfo->tcpName,true);
}
//ARMARX_IMPORTANT_S << "RemoteRobot local clone end" << flush;
return robo;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment