mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-09 19:10:38 +00:00
(svn r2813) Plug a thread leak and prevent a race condition which could lead to multiple simultaneous saves and therefore severe corruption
This commit is contained in:
parent
747a0f6a55
commit
eb826dfb66
@ -1245,8 +1245,6 @@ static void* SaveFileToDisk(void* arg)
|
|||||||
|
|
||||||
tmp = _sl.buf;
|
tmp = _sl.buf;
|
||||||
|
|
||||||
SaveFileStart();
|
|
||||||
|
|
||||||
/* XXX - Setup setjmp error handler if an error occurs anywhere deep during
|
/* XXX - Setup setjmp error handler if an error occurs anywhere deep during
|
||||||
* loading/saving execute a longjmp() and continue execution here */
|
* loading/saving execute a longjmp() and continue execution here */
|
||||||
if (setjmp(_sl.excpt)) {
|
if (setjmp(_sl.excpt)) {
|
||||||
@ -1325,6 +1323,8 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode)
|
|||||||
WaitTillSaved();
|
WaitTillSaved();
|
||||||
// nonsense to do an autosave while we were still saving our game, so skip it
|
// nonsense to do an autosave while we were still saving our game, so skip it
|
||||||
if (_do_autosave) return SL_OK;
|
if (_do_autosave) return SL_OK;
|
||||||
|
} else {
|
||||||
|
WaitTillSaved();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load a TTDLX or TTDPatch game */
|
/* Load a TTDLX or TTDPatch game */
|
||||||
@ -1390,6 +1390,7 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode)
|
|||||||
SlWriteFill(); // flush the save buffer
|
SlWriteFill(); // flush the save buffer
|
||||||
|
|
||||||
/* Write to file */
|
/* Write to file */
|
||||||
|
SaveFileStart();
|
||||||
if (_network_server ||
|
if (_network_server ||
|
||||||
(save_thread = OTTDCreateThread(&SaveFileToDisk, NULL)) == NULL) {
|
(save_thread = OTTDCreateThread(&SaveFileToDisk, NULL)) == NULL) {
|
||||||
DEBUG(misc, 1) ("cannot create savegame thread, reverting to single-threaded mode...");
|
DEBUG(misc, 1) ("cannot create savegame thread, reverting to single-threaded mode...");
|
||||||
|
Loading…
Reference in New Issue
Block a user