Changeset 642847c


Ignore:
Timestamp:
05/01/15 09:03:57 (4 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, releng/10.2, stable/10
Children:
50f598a
Parents:
01feab7
Message:

A couple other final fixes for syscache:
1) Check for a stale pipe file and remove it if possible (before starting)
2) Move the "freebsd-update" command usage into a seperate long-lived process which will not prevent the main syncer from running/re-running as necessary (it will just skip the system sync if that process is still running).

Location:
src-sh/syscache/daemon
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src-sh/syscache/daemon/DB.cpp

    r4fec4bd r642847c  
    584584Syncer::Syncer(QObject *parent, QHash<QString,QString> *hash) : QObject(parent){ 
    585585  HASH = hash; 
     586  longProc = new QProcess(this); 
     587    longProc->setProcessEnvironment(QProcessEnvironment::systemEnvironment()); 
     588    longProc->setProcessChannelMode(QProcess::MergedChannels);    
     589    connect(longProc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(LongProcFinished(int, QProcess::ExitStatus)) ); 
    586590} 
    587591 
    588592Syncer::~Syncer(){ 
    589593  stopping = true; 
     594  if(longProc->state() != QProcess::NotRunning){ 
     595    longProc->kill(); 
     596  } 
    590597} 
    591598 
     
    730737 
    731738bool Syncer::needsSysSync(){ 
    732   //Check how log the  
     739  //Check how long since the last check the 
     740  if(longProc->state() != QProcess::NotRunning){ return false; } //currently running 
    733741  if(!HASH->contains("System/lastSyncTimeStamp")){ return true; } 
    734742  else{ 
     
    11781186void Syncer::syncSysStatus(){ 
    11791187  if(needsSysSync()){ 
    1180     QStringList info = directSysCmd("pc-updatemanager check"); 
     1188    longProc->start("pc-updatemanager check"); 
     1189  } 
     1190} 
     1191 
     1192void Syncer::ParseSysStatus(QStringList info){ 
    11811193    //Save the raw output for later 
    11821194    HASH->insert("System/updateLog", info.join("<br>")); 
     
    12221234    //Now save the last time this was updated 
    12231235    HASH->insert("System/lastSyncTimeStamp", QString::number(QDateTime::currentMSecsSinceEpoch()) ); 
    1224   } 
    12251236} 
    12261237 
     
    13201331  HASH->insert("PBI/lastSyncTimeStamp", QString::number(QDateTime::currentMSecsSinceEpoch())); 
    13211332} 
     1333 
     1334void Syncer::LongProcFinished(int ret, QProcess::ExitStatus status){ 
     1335  qDebug() << "System Status Update Finished:" << ret << status; 
     1336  QStringList info; 
     1337     QString tmp = longProc->readAllStandardOutput(); 
     1338     if(tmp.endsWith("\n")){ tmp.chop(1); } 
     1339  info = tmp.split("\n"); 
     1340  //Only the system status run uses this right now, but we could add parsing/usage for other syncs here later 
     1341  ParseSysStatus(info); 
     1342} 
  • src-sh/syscache/daemon/DB.h

    rd87bb00 r642847c  
    3636private: 
    3737        QHash<QString,QString> *HASH; 
     38        QProcess *longProc; 
    3839        bool stopping; 
    3940 
     
    6667        void syncPkgRemoteJail(QString jail); 
    6768        void syncPkgRemote(); 
    68         void syncSysStatus(); 
     69        void syncSysStatus(); //this is run as a long process (non-blocking) 
     70        void ParseSysStatus(QStringList info); //process finished, parse the outputs 
    6971        void syncPbi(); 
     72 
     73        //Special slot for long precesses 
     74        void LongProcFinished(int, QProcess::ExitStatus); 
    7075 
    7176signals: 
  • src-sh/syscache/daemon/syscache-daemon.cpp

    r6cfdf00 r642847c  
    1616//General Start/Stop functions 
    1717bool SysCacheDaemon::startServer(){ 
     18  if( !QLocalServer::removeServer("/var/run/syscache.pipe") ){ 
     19    qDebug() << "A previous instance of the syscache server is still running! Exiting...";         
     20    exit(1); 
     21  } 
    1822  if( server->listen("/var/run/syscache.pipe") ){ 
    1923    QFile::setPermissions("/var/run/syscache.pipe", QFile::ReadUser | QFile::WriteUser | QFile::ReadGroup | QFile::WriteGroup | QFile::ReadOther | QFile::WriteOther); 
Note: See TracChangeset for help on using the changeset viewer.