Fix a race-condition when two games have been started simultaneously and attempt to create the same replay directory, refs #3255.

Instead of triggering a debug-breakpoint, print a warning to stdout and
succeed in the N'th retry when having started N processes
simultaneously.
Previously the problem had been addressed by using the processID in the
directory name.

This was SVN commit r17776.
This commit is contained in:
elexis
2016-02-19 11:22:32 +00:00
parent 4cda0b7040
commit a32ed75bff
5 changed files with 19 additions and 8 deletions
-2
View File
@@ -298,7 +298,6 @@ void CSimulation2Impl::ReportSerializationFailure(
{
const OsPath path = getDateIndexSubdirectory(psLogDir() / "serializationtest");
debug_printf("Writing serializationtest-data to %s\n", path.string8().c_str());
CreateDirectories(path, 0700);
// Clean up obsolete files from previous runs
wunlink(path / "hash.before.a");
@@ -554,7 +553,6 @@ void CSimulation2Impl::DumpState()
std::stringstream name;\
name << std::setw(5) << std::setfill('0') << m_TurnNumber << ".txt";
const OsPath path = m_OOSLogPath / name.str();
CreateDirectories(path.Parent(), 0700);
std::ofstream file (OsString(path).c_str(), std::ofstream::out | std::ofstream::trunc);
file << "State hash: " << std::hex;