2023-05-16 Fred Gleason <fredg@paravelsystems.com>

* Refactored rdrssd(8) to process feeds at two seconds after each
	minute.

Signed-off-by: Fred Gleason <fredg@paravelsystems.com>
This commit is contained in:
Fred Gleason
2023-05-16 17:24:34 -04:00
parent 4adc7fa066
commit 91531f6baa
3 changed files with 18 additions and 17 deletions

View File

@@ -34,11 +34,8 @@ MainObject::MainObject(QObject *parent)
: QObject(parent)
{
QString err_msg;
bool ok=false;
RDApplication::ErrorType err_type=RDApplication::ErrorOk;
d_process_interval=RDRSSD_DEFAULT_PROCESS_INTERVAL;
//
// Open the Database
//
@@ -68,15 +65,6 @@ MainObject::MainObject(QObject *parent)
// Read Command Options
//
for(unsigned i=0;i<rda->cmdSwitch()->keys();i++) {
if(rda->cmdSwitch()->key(i)=="--process-interval") {
d_process_interval=1000*rda->cmdSwitch()->value(i).toInt(&ok);
if((!ok)||(d_process_interval<=0)) {
fprintf(stderr,
"rdrssd: invalid value specified for --process-interval\n");
exit(1);
}
rda->cmdSwitch()->setProcessed(i,true);
}
if(!rda->cmdSwitch()->processed(i)) {
rda->syslog(LOG_ERR,"unknown command option \"%s\"",
(const char *)rda->cmdSwitch()->key(i).toUtf8());
@@ -96,7 +84,8 @@ MainObject::MainObject(QObject *parent)
d_timer=new QTimer(this);
d_timer->setSingleShot(true);
connect(d_timer,SIGNAL(timeout()),this,SLOT(timeoutData()));
d_timer->start(0);
StartTimer();
rda->syslog(LOG_DEBUG,"started");
}
@@ -117,7 +106,17 @@ void MainObject::timeoutData()
}
delete q;
d_timer->start(d_process_interval);
StartTimer();
}
void MainObject::StartTimer()
{
QDateTime now=QDateTime::currentDateTime();
QDateTime then=now.addSecs(60);
then.setTime(QTime(then.time().hour(),then.time().minute(),2));
d_timer->start(now.msecsTo(then));
}