From 5f284ae1fa3bf6e7dc11e1354e0e7edf492e93b6 Mon Sep 17 00:00:00 2001 From: mkr Date: Fri, 9 Feb 2007 13:55:38 +0000 Subject: [PATCH] Fix for bug IPAL14711 : Porting problem: "omniORB.CORBA.COMM_FAILURE" is raised after start dataflow execution. --- .../DataFlowExecutor_FiniteStateMachine.cxx | 7 +++++++ .../DataFlowExecutor_FiniteStateMachine.hxx | 2 ++ src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx | 1 + src/GraphExecutor/DataFlowExecutor_OutNode.cxx | 10 +++++++++- src/GraphExecutor/DataFlowExecutor_OutNode.hxx | 4 ++++ 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.cxx b/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.cxx index 8408f5c..36b70bf 100644 --- a/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.cxx +++ b/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.cxx @@ -728,6 +728,13 @@ void GraphExecutor::FiniteStateMachine::JoinThread( pthread_t aThread ) { } } +int GraphExecutor::FiniteStateMachine::ThreadsNumber() { + if( _ThreadList.begin() == _ThreadList.end() ) + return 0; + else + return _ThreadList.size(); +} + ostream & operator<< (ostream &f ,const GraphExecutor::AutomatonState & aState ) { switch (aState) { case GraphExecutor::UnKnownState : diff --git a/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.hxx b/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.hxx index 40f2c06..257c208 100644 --- a/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.hxx +++ b/src/GraphExecutor/DataFlowExecutor_FiniteStateMachine.hxx @@ -233,6 +233,8 @@ namespace GraphExecutor { void JoinThread() ; void JoinThread( pthread_t aThread ) ; + int ThreadsNumber() ; // mkr : IPAL14711 + const char * ControlStateName( const SUPERV::ControlState & aState ) const { return _ControlStateName[ aState ] ; } ; const char * StateName( const GraphExecutor::AutomatonState & aState ) const { diff --git a/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx b/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx index 5008881..1f48695 100644 --- a/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx +++ b/src/GraphExecutor/DataFlowExecutor_InNodeThreads.cxx @@ -637,6 +637,7 @@ int GraphExecutor::InNode::executeAction() { delete [] msg ; pthread_exit( msg ) ; } + _OutNode->setRunFuncThread( T ) ; // mkr : IPAL14711 #if ActionsTrace cdebug << pthread_self() << "/" << ThreadNo() << " " << Name() << " executeAction has created thread " << T << endl ; diff --git a/src/GraphExecutor/DataFlowExecutor_OutNode.cxx b/src/GraphExecutor/DataFlowExecutor_OutNode.cxx index 20359ef..44eb527 100644 --- a/src/GraphExecutor/DataFlowExecutor_OutNode.cxx +++ b/src/GraphExecutor/DataFlowExecutor_OutNode.cxx @@ -55,6 +55,7 @@ GraphExecutor::OutNode::OutNode() { _ControlState = SUPERV::VoidState ; _State = GraphExecutor::UnKnownState ; _PyInitialized = false ; + _run_func_thread = 0; pthread_mutex_init( &_MutexWait , NULL ) ; pthread_mutex_init( &_PyMutexWait , NULL ) ; if ( pthread_cond_init( &_EventWait , NULL ) ) { @@ -96,6 +97,7 @@ GraphExecutor::OutNode::OutNode( CORBA::ORB_ptr ORB, _ControlState = SUPERV::VoidState ; _State = GraphExecutor::UnKnownState ; _PyInitialized = false ; + _run_func_thread = 0; _Orb = CORBA::ORB::_duplicate( ORB ) ; pthread_mutex_init( &_MutexWait , NULL ) ; pthread_mutex_init( &_PyMutexWait , NULL ) ; @@ -159,6 +161,7 @@ GraphExecutor::OutNode::OutNode( CORBA::ORB_ptr ORB, _ControlState = SUPERV::VoidState ; _State = GraphExecutor::UnKnownState ; _PyInitialized = false ; + _run_func_thread = 0; _Orb = CORBA::ORB::_duplicate( ORB ) ; pthread_mutex_init( &_MutexWait , NULL ) ; pthread_mutex_init( &_PyMutexWait , NULL ) ; @@ -836,7 +839,7 @@ void GraphExecutor::OutNode::CheckAllDone() { MESSAGE("================================================================================") ; cdebug << "================================================================================" << endl ; cdebug << Name() << " IS DONE : " << theAutomaton->StateName( AutomatonState() ) << " EventQSize " - << EventQSize() << endl ; + << EventQSize() << endl ; cdebug << "================================================================================" << endl ; //PAL8520 @@ -957,6 +960,7 @@ void GraphExecutor::OutNode::ExitThread( pthread_t ThreadNumber ) { cdebug << pthread_self() << " ExitThread( " << ThreadNumber << " ) " << _Threads << " running threads " << _SuspendedThreads << " suspended threads IsDone() " << IsDone() ; + _run_func_thread = 0 ; // mkr : IPAL14711 if ( IsDone() ) { cdebug << " ==> theAutomaton->Executed() " << endl ; theAutomaton->Executed() ; @@ -2144,6 +2148,10 @@ bool GraphExecutor::OutNode::DoneWait() { perror("pthread_mutex_lock _DoneWait") ; exit( 0 ) ; } + while ( _run_func_thread || theAutomaton->ThreadsNumber() ) { + // mkr : IPAL14711 + // waiting for pthread_join in FiniteStateMachine + } if ( Done() || IsKilled() ) Graph()->GraphEditor()->Editing(); // mkr : IPAL14572 : calling Editing() to indicate stop of execution cdebug_out << pthread_self() << " GraphExecutor::DoneWait " << this << " " << Name() << " " << State() << " : " << aret << endl ; diff --git a/src/GraphExecutor/DataFlowExecutor_OutNode.hxx b/src/GraphExecutor/DataFlowExecutor_OutNode.hxx index 200d42b..4a2a7da 100644 --- a/src/GraphExecutor/DataFlowExecutor_OutNode.hxx +++ b/src/GraphExecutor/DataFlowExecutor_OutNode.hxx @@ -70,6 +70,8 @@ namespace GraphExecutor { list< GraphExecutor::NodeEvent > _Events ; list< GraphExecutor::AutomatonState > _States ; + pthread_t _run_func_thread ; + bool Valid() ; void UnValid() ; bool Executable() ; @@ -269,6 +271,8 @@ namespace GraphExecutor { const char *FromParameterName ) ; const long CpuUsed() ; const long CpuUsed( const char *aNodeName ) ; + + void setRunFuncThread( pthread_t theThread ) { _run_func_thread = theThread; } ; // mkr : IPAL14711 }; }; -- 2.39.2