2017-05-23 Fred Gleason <fredg@paravelsystems.com>

* Modified ripcd(8) to allow switcher drivers to execute cleanup
	code at program shutdown.
This commit is contained in:
Fred Gleason 2017-05-23 10:43:34 -04:00
parent 3b14fbfa10
commit c50be5b262
3 changed files with 28 additions and 9 deletions

View File

@ -15801,3 +15801,6 @@
* Added an 'RDMatrix::KernelGpio' element to the 'RDMatrix::Type enum.
* Implemented a Kernel GPIO switcher driver in 'ripcd/kernelgpio.cpp'
and 'ripcd/kernelgpio.h'.
2017-05-23 Fred Gleason <fredg@paravelsystems.com>
* Modified ripcd(8) to allow switcher drivers to execute cleanup
code at program shutdown.

View File

@ -55,7 +55,7 @@
RDConfig *ripcd_config;
RDCae *rdcae;
RDStation *rdstation;
bool global_exiting=false;
void SigHandler(int signo)
{
@ -73,15 +73,8 @@ void SigHandler(int signo)
return;
case SIGTERM:
LogLine(RDConfig::LogInfo,"ripcd exiting normally");
RDDeletePid(RD_PID_DIR,"ripcd.pid");
exit(0);
break;
case SIGINT:
LogLine(RDConfig::LogInfo,"ripcd exiting on SIGINT");
RDDeletePid(RD_PID_DIR,"ripcd.pid");
exit(0);
global_exiting=true;
break;
}
}
@ -249,6 +242,13 @@ MainObject::MainObject(QObject *parent)
log(RDConfig::LogInfo,"maintenance checks disabled on this host!");
}
//
// Exit Timer
//
timer=new QTimer(this);
connect(timer,SIGNAL(timeout()),this,SLOT(exitTimerData()));
timer->start(200);
LogLine(RDConfig::LogInfo,"started");
}
@ -408,6 +408,21 @@ void MainObject::macroTimerData(int num)
}
void MainObject::exitTimerData()
{
if(global_exiting) {
for(int i=0;i<MAX_MATRICES;i++) {
if(ripcd_switcher[i]!=NULL) {
delete ripcd_switcher[i];
}
}
LogLine(RDConfig::LogInfo,"ripcd exiting normally");
RDDeletePid(RD_PID_DIR,"ripcd.pid");
exit(0);
}
}
void MainObject::SetUser(QString username)
{
rdstation->setUserName(username);

View File

@ -77,6 +77,7 @@ class MainObject : public QObject
void socketData(int);
void socketKill(int);
void checkMaintData();
void exitTimerData();
private:
void SetUser(QString username);