mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 00:31:14 +00:00
Gracefully end the device also in the termination case (instead of abort).
This commit is contained in:
parent
ce42f36126
commit
e9f09143b2
|
@ -80,29 +80,29 @@ void FairMQDevice::SignalHandler(int signal)
|
||||||
{
|
{
|
||||||
LOG(INFO) << "Caught signal " << signal;
|
LOG(INFO) << "Caught signal " << signal;
|
||||||
|
|
||||||
fState = EXITING;
|
if (!fTerminated)
|
||||||
Unblock();
|
{
|
||||||
fStateThread.interrupt();
|
ChangeState(STOP);
|
||||||
fStateThread.join();
|
|
||||||
|
|
||||||
fTerminateStateThread = boost::thread(boost::bind(&FairMQDevice::Terminate, this));
|
ChangeState(RESET_TASK);
|
||||||
Shutdown();
|
WaitForEndOfState(RESET_TASK);
|
||||||
fTerminateStateThread.join();
|
|
||||||
|
ChangeState(RESET_DEVICE);
|
||||||
|
WaitForEndOfState(RESET_DEVICE);
|
||||||
|
|
||||||
|
ChangeState(END);
|
||||||
|
|
||||||
stop();
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
// fRunning = false;
|
|
||||||
// if (!fTerminated)
|
|
||||||
// {
|
|
||||||
// fTerminated = true;
|
|
||||||
// LOG(INFO) << "Exiting.";
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// LOG(WARN) << "Repeated termination or bad initialization? Aborting.";
|
|
||||||
// // std::abort();
|
|
||||||
// exit(EXIT_FAILURE);
|
// exit(EXIT_FAILURE);
|
||||||
// }
|
fRunning = false;
|
||||||
|
fTerminated = true;
|
||||||
|
LOG(INFO) << "Exiting.";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG(WARN) << "Repeated termination or bad initialization? Aborting.";
|
||||||
|
// std::abort();
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQDevice::ConnectChannels(list<FairMQChannel*>& chans)
|
void FairMQDevice::ConnectChannels(list<FairMQChannel*>& chans)
|
||||||
|
@ -769,31 +769,31 @@ void FairMQDevice::InteractiveStateLoop()
|
||||||
{
|
{
|
||||||
case 'i':
|
case 'i':
|
||||||
LOG(INFO) << "[i] init device";
|
LOG(INFO) << "[i] init device";
|
||||||
ChangeState("INIT_DEVICE");
|
ChangeState(INIT_DEVICE);
|
||||||
break;
|
break;
|
||||||
case 'j':
|
case 'j':
|
||||||
LOG(INFO) << "[j] init task";
|
LOG(INFO) << "[j] init task";
|
||||||
ChangeState("INIT_TASK");
|
ChangeState(INIT_TASK);
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
LOG(INFO) << "[p] pause";
|
LOG(INFO) << "[p] pause";
|
||||||
ChangeState("PAUSE");
|
ChangeState(PAUSE);
|
||||||
break;
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
LOG(INFO) << "[r] run";
|
LOG(INFO) << "[r] run";
|
||||||
ChangeState("RUN");
|
ChangeState(RUN);
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
LOG(INFO) << "[s] stop";
|
LOG(INFO) << "[s] stop";
|
||||||
ChangeState("STOP");
|
ChangeState(STOP);
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
LOG(INFO) << "[t] reset task";
|
LOG(INFO) << "[t] reset task";
|
||||||
ChangeState("RESET_TASK");
|
ChangeState(RESET_TASK);
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
LOG(INFO) << "[d] reset device";
|
LOG(INFO) << "[d] reset device";
|
||||||
ChangeState("RESET_DEVICE");
|
ChangeState(RESET_DEVICE);
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
LOG(INFO) << "[h] help";
|
LOG(INFO) << "[h] help";
|
||||||
|
@ -801,11 +801,11 @@ void FairMQDevice::InteractiveStateLoop()
|
||||||
break;
|
break;
|
||||||
// case 'x':
|
// case 'x':
|
||||||
// LOG(INFO) << "[x] ERROR";
|
// LOG(INFO) << "[x] ERROR";
|
||||||
// ChangeState("ERROR_FOUND");
|
// ChangeState(ERROR_FOUND);
|
||||||
// break;
|
// break;
|
||||||
case 'q':
|
case 'q':
|
||||||
LOG(INFO) << "[q] end";
|
LOG(INFO) << "[q] end";
|
||||||
ChangeState("END");
|
ChangeState(END);
|
||||||
if (CheckCurrentState("EXITING"))
|
if (CheckCurrentState("EXITING"))
|
||||||
{
|
{
|
||||||
fRunning = false;
|
fRunning = false;
|
||||||
|
|
|
@ -343,7 +343,7 @@ struct FairMQFSM_ : public msm::front::state_machine_def<FairMQFSM_>
|
||||||
virtual void Terminate() {} // Termination method called during StopFct action.
|
virtual void Terminate() {} // Termination method called during StopFct action.
|
||||||
virtual void Unblock() {} // Method to send commands.
|
virtual void Unblock() {} // Method to send commands.
|
||||||
|
|
||||||
// Transition table for FairMQFMS
|
// Transition table for FairMQFSM
|
||||||
struct transition_table : mpl::vector<
|
struct transition_table : mpl::vector<
|
||||||
// Start Event Next Action Guard
|
// Start Event Next Action Guard
|
||||||
// +------------------------+----------------------+------------------------+----------------+---------+
|
// +------------------------+----------------------+------------------------+----------------+---------+
|
||||||
|
@ -369,7 +369,7 @@ struct FairMQFSM_ : public msm::front::state_machine_def<FairMQFSM_>
|
||||||
template <class FSM, class Event>
|
template <class FSM, class Event>
|
||||||
void no_transition(Event const& e, FSM&, int state)
|
void no_transition(Event const& e, FSM&, int state)
|
||||||
{
|
{
|
||||||
LOG(STATE) << "no transition from state " << GetStateName(state) << " on event " << e.name();
|
LOG(STATE) << "no transition from state " << GetStateName(state) << " (" << state << ") on event " << e.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
// backward compatibility to FairMQStateMachine
|
// backward compatibility to FairMQStateMachine
|
||||||
|
|
|
@ -48,6 +48,8 @@ inline int runStateMachine(TMQDevice& device, FairMQProgOptions& config)
|
||||||
{
|
{
|
||||||
device.WaitForEndOfState(TMQDevice::RUN);
|
device.WaitForEndOfState(TMQDevice::RUN);
|
||||||
|
|
||||||
|
if (!device.CheckCurrentState(TMQDevice::EXITING))
|
||||||
|
{
|
||||||
device.ChangeState(TMQDevice::RESET_TASK);
|
device.ChangeState(TMQDevice::RESET_TASK);
|
||||||
device.WaitForEndOfState(TMQDevice::RESET_TASK);
|
device.WaitForEndOfState(TMQDevice::RESET_TASK);
|
||||||
|
|
||||||
|
@ -56,6 +58,7 @@ inline int runStateMachine(TMQDevice& device, FairMQProgOptions& config)
|
||||||
|
|
||||||
device.ChangeState(TMQDevice::END);
|
device.ChangeState(TMQDevice::END);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG(ERROR) << "Requested control mechanism '" << control << "' is not available.";
|
LOG(ERROR) << "Requested control mechanism '" << control << "' is not available.";
|
||||||
|
|
Loading…
Reference in New Issue
Block a user