Changeset 53791e4


Ignore:
Timestamp:
07/31/13 07:00:38 (13 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3
Children:
ee5d82a
Parents:
d515a9e
Message:

Add a better system of locking when GUIs can run freebsd-update, this will prevent
some messed up situations where a current freebsd-update is being screwed up by another
running process.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/pc-systemupdatertray/UpdaterTray.cpp

    rd515a9e r53791e4  
    384384  ///////////////////////////////////////////// 
    385385 
    386   // KPM Lets skip this if pc-updategui is open, having two freebsd-updates running at same time 
     386  // KPM Lets skip this if pc-fbsdupdatecheck is open, having two freebsd-updates running at same time 
    387387  // Cause *bad* things to happen 
    388   int ret = QProcess::execute("pgrep", QStringList() << "pc-updategui"); 
    389   if ( ret != 0 ) { 
     388  if ( ! QFile::exists("/tmp/.fbsdup-lock") ) { 
    390389    qDebug() << "Checking for freebsd-updates!"; 
    391390 
  • src-qt4/pc-updategui/mainWin.cpp

    r7381613 r53791e4  
    169169    } 
    170170 
     171    // Remove the lock file 
     172    if ( listUpdates.at(curUpdate).at(1) == "FBSDUPDATE" ) { 
     173        system("rm /tmp/.fbsdup-lock"); 
     174    } 
     175 
    171176    listViewUpdates->item(curUpdate)->setIcon(QIcon()); 
    172177    setWindowTitle(tr("Update Manager")); 
     
    177182    if ( listViewUpdates->item(z)->checkState() == Qt::Checked && curUpdate < z )  
    178183    { 
     184         
     185      // Check for a freebsd-update lock file 
     186      if ( listUpdates.at(z).at(1) == "FBSDUPDATE" ) { 
     187        if ( QFile::exists("/tmp/.fbsdup-lock") ) { 
     188          QMessageBox::critical(this, tr("Update Failed!"), tr("Could not run freebsd-update, another process is already running!"));  
     189          slotUpdateFinished(); 
     190          return; 
     191        }  
     192        // Lock out freebsd-update 
     193        system("touch /tmp/.fbsdup-lock"); 
     194      } 
     195 
    179196      curUpdate = z; 
    180197      curUpdateIndex++; 
     
    527544  QString line, toPatchVer, tmp; 
    528545  QStringList up, listDesc, listPkgs; 
     546 
     547  if ( QFile::exists("/tmp/.fbsdup-lock") ) { 
     548     qDebug() << "Skipping update check - freebsd-update is running elsewhere"; 
     549     return; 
     550  } 
    529551 
    530552  // Now check if there are freebsd-updates to install 
  • src-sh/pc-fbsdupdatecheck/main.c

    r1620346 r53791e4  
    99int main() 
    1010{ 
     11        system("touch /tmp/.fbsdup-lock"); 
    1112        system("cat /usr/sbin/freebsd-update | sed 's|! -t 0|-z '1'|g' | /bin/sh -s 'fetch'"); 
     13        system("rm /tmp/.fbsdup-lock"); 
    1214        return 0; 
    1315} 
Note: See TracChangeset for help on using the changeset viewer.