From 05a76d53c0ff99f698760080c2fbde7f1e47cf7a Mon Sep 17 00:00:00 2001 From: David Cole Date: Fri, 9 Mar 2012 11:39:01 -0500 Subject: CPack: Fix retry logic when calls to hdiutil fail The long-standing sporadic failures of CPack tests on the Mac dashboards are caused by an occasional problem running hdiutil. To compensate for this, a retry loop was added in the code in a previous commit: a9fa71a4 ... but the logic for breaking out of the retry loop was flawed, breaking out of the loop (and not retrying) when the hdiutil command returns an error instead of when it returns success. This commit fixes the flawed logic, bumps up the number of retries from 4 to 10, and adds a half-second delay in between retries. The delay is specifically added in case a virus checker or spotlight indexer is temporarily causing the hdiutil failure by hanging onto a newly created file longer than hdiutil expects it to. As with all sporadically occurring issues, we'll never know if this is really fixed all the way. But I'll be happy even if we can only get it to happen just a bit less often. --- Source/CPack/cmCPackOSXX11Generator.cxx | 8 +++++--- Source/CPack/cmCPackPackageMakerGenerator.cxx | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx index 75ad640..363ccea 100644 --- a/Source/CPack/cmCPackOSXX11Generator.cxx +++ b/Source/CPack/cmCPackOSXX11Generator.cxx @@ -170,23 +170,25 @@ int cmCPackOSXX11Generator::PackageFiles() << "\" create -ov -format UDZO -srcfolder \"" << diskImageDirectory.c_str() << "\" \"" << packageFileNames[0] << "\""; - int retVal = 1; cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Compress disk image using command: " << dmgCmd.str().c_str() << std::endl); // since we get random dashboard failures with this one // try running it more than once - int numTries = 4; + int retVal = 1; + int numTries = 10; bool res = false; while(numTries > 0) { res = cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output, &retVal, 0, this->GeneratorVerbose, 0); - if(res && retVal) + if ( res && !retVal ) { numTries = -1; + break; } + cmSystemTools::Delay(500); numTries--; } if ( !res || retVal ) diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx index 0c4b1a6..327c4a6 100644 --- a/Source/CPack/cmCPackPackageMakerGenerator.cxx +++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx @@ -319,17 +319,19 @@ int cmCPackPackageMakerGenerator::PackageFiles() << "\" \"" << packageFileNames[0] << "\""; std::string output; int retVal = 1; - int numTries = 4; + int numTries = 10; bool res = false; while(numTries > 0) { res = cmSystemTools::RunSingleCommand(dmgCmd.str().c_str(), &output, &retVal, 0, this->GeneratorVerbose, 0); - if(res && retVal) + if ( res && !retVal ) { numTries = -1; + break; } + cmSystemTools::Delay(500); numTries--; } if ( !res || retVal ) -- cgit v0.12