Changeset 1017

Show
Ignore:
Timestamp:
08/16/10 13:38:04 (18 months ago)
Author:
robert
Message:

From Brad Christiansen,

"I have made changes in two areas that effect VPBMaster's operation. The motivation for the changes come from writing a GUI front end to VPBMaster.

The first is changes to the logging behavior:
- If a master log file is set, this is now also used as the operations log. This adds more detail to the master log file (it is clearer what has happened, particularly in the case of errors).
- Fixed a bug which meant the build log was not correctly passed to the DataSet?.

The second set of changes relate to the behavior of VPBMaster when a run is finished. Prior to my changes the VPBMaster executable would not terminate if the TaskManager? had spawned any threads, even once all tasks had completed. To change this behavior so VPBMaster would exit on completion I made two changes:

- Implemented the exit(int) function in TaskManager? (it was defined in the header but had no implementation)
- Called this method prior to VPBMaster returning from main so all thread are closed and VPBMaster exits cleanly."

Second submission:

"The return value of TaskManager?'s run method was ignored by vpbmaster, thus is the task manager failed to complete all its tasks, vpbmaster would still return 0. My change to vpbmaster checks the return value of TaskManager? run and sets the return value to 1 if the run method returns false."

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/applications/vpbmaster/vpbmaster.cpp

    r998 r1017  
    6868    if (arguments.read("-h") || arguments.read("--help")) 
    6969    { 
    70         arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION); 
     70        arguments.getApplicationUsage()->write(std::cout,osg::ApplicationUsage::COMMAND_LINE_OPTION);         
    7171        return 1; 
    7272    } 
     
    123123                } 
    124124                std::cout<< " : "<<itr->second.description<<std::endl; 
    125             } 
    126  
     125            }             
    127126            return 1; 
    128127        } 
     
    145144        if (arguments.errors()) 
    146145        { 
    147             arguments.writeErrorMessages(std::cout); 
     146            arguments.writeErrorMessages(std::cout);             
     147            taskManager->exit(SIGTERM); 
    148148            return 1; 
    149149        } 
     
    156156 
    157157            taskManager->writeSource(tasksOutputFileName); 
    158             taskManager->writeTasks(tasksOutputFileName, true); 
     158            taskManager->writeTasks(tasksOutputFileName, true);  
     159            taskManager->exit(SIGTERM); 
    159160            return 1; 
    160161        } 
     
    178179                    { 
    179180                        // nothing to do. 
     181                        taskManager->exit(SIGTERM); 
    180182                        return 1; 
    181183                    } 
     
    206208                if (taskManager->hasMachines()) 
    207209                { 
    208                     taskManager->run(); 
     210                    if(!taskManager->run())  
     211                    { 
     212                        result = 1; 
     213                    } 
     214                     
    209215                } 
    210216                else 
     
    235241 
    236242    // make sure the OS writes changes to disk 
    237     vpb::sync(); 
    238  
     243    vpb::sync();     
     244    taskManager->log(osg::NOTICE,"Run Complete.");    
     245    taskManager->exit(SIGTERM); 
    239246    return result; 
    240247} 
  • trunk/src/vpb/TaskManager.cpp

    r998 r1017  
    242242    while (arguments.read("--master-log",logFileName)) 
    243243    { 
    244         setBuildLog(new BuildLog(logFileName)); 
     244        BuildLog* bl = new BuildLog(logFileName); 
     245        setBuildLog(bl); 
     246        pushOperationLog(bl); 
    245247    } 
    246248 
     
    408410        vpb::BuildOptions* bo = db ? db->getBuildOptions() : 0; 
    409411 
    410         if (bo && !(bo->getLogFileName().empty())) 
    411         { 
    412             dataset->setBuildLog(new vpb::BuildLog); 
    413         } 
     412        if (getBuildLog()) 
     413        { 
     414            dataset->setBuildLog(getBuildLog()); 
     415        } 
     416        else if (bo && !(bo->getLogFileName().empty())) 
     417        { 
     418            dataset->setBuildLog(new vpb::BuildLog(bo->getLogFileName())); 
     419        } 
     420         
    414421 
    415422        if (_taskFile.valid()) 
     
    10181025} 
    10191026 
     1027void TaskManager::exit(int sig) 
     1028{ 
     1029    handleSignal(sig); 
     1030    setDone(true); 
     1031} 
     1032 
    10201033void TaskManager::handleSignal(int sig) 
    10211034{