Skip to content

Commit

Permalink
fix(tform): restrict sort file creation check to main thread
Browse files Browse the repository at this point in the history
Restrict the sort file creation check at startup to the main thread in
TFORM. This change prevents unnecessary checks and potential race
conditions caused by multiple threads.

Close #602.
  • Loading branch information
tueda committed Jan 24, 2025
1 parent 853698c commit fa83e5f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions sources/startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,9 @@ classic:;
/*
Try to create the sort file already, so we can Terminate earlier if this fails.
*/
#ifdef WITHPTHREADS
if ( par <= 1 ) {
#endif
if ( ( AM.S0->file.handle = CreateFile((char *)AM.S0->file.name) ) < 0 ) {
MesPrint("Could not create sort file: %s", AM.S0->file.name);
Terminate(-1);
Expand All @@ -810,6 +813,9 @@ classic:;
CloseFile(AM.S0->file.handle);
AM.S0->file.handle = -1;
remove(AM.S0->file.name);
#ifdef WITHPTHREADS
}
#endif
/*
With the stage4 and scratch file names we have to be a bit more careful.
They are to be allocated after the threads are initialized when there
Expand Down

0 comments on commit fa83e5f

Please sign in to comment.