From: H.G. Muller Date: Fri, 30 Jul 2010 21:10:42 +0000 (+0200) Subject: Fix deadlock in match-result display X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=fd3bdfd7587b74332180fc829650ce4681890979;p=xboard.git Fix deadlock in match-result display At the end of a match, GameEnds() was recursively calling itself, through DisplayFatalError() and ExitEvent(), and the latter was then delaying until the calling GameEnds() terminated. (Which it would of course never do before ExitEvent returned; fortunately there was a tim limit to this delay, but in XBoard it was 10 sec in stead of 10 msec.) Now the calling of DisplayFatalError() (to show the result popup) is delayed until after GameEnds completes (and resets the anti-recursion flag 'endingGame'), so that it is simply executed a second time, unaware of the earlier call. But this second time it does not do anything, because the gameMode ws set to EndOfGame the first time, and the writing of the PGN is blocked by the checksum being still the same. --- diff --git a/backend.c b/backend.c index a76adef..99aceae 100644 --- a/backend.c +++ b/backend.c @@ -8988,7 +8988,7 @@ GameEnds(result, resultDetails, whosays) { GameMode nextGameMode; int isIcsGame; - char buf[MSG_SIZ]; + char buf[MSG_SIZ], popupRequested = 0; if(endingGame) return; /* [HGM] crash: forbid recursion */ endingGame = 1; @@ -9330,7 +9330,7 @@ GameEnds(result, resultDetails, whosays) first.tidy, second.tidy, first.matchWins, second.matchWins, appData.matchGames - (first.matchWins + second.matchWins)); - DisplayFatalError(buf, 0, 0); + popupRequested++; // [HGM] crash: postpone to after resetting endingGame } } if ((gameMode == AnalyzeMode || gameMode == AnalyzeFile) && @@ -9339,6 +9339,7 @@ GameEnds(result, resultDetails, whosays) gameMode = nextGameMode; ModeHighlight(); endingGame = 0; /* [HGM] crash */ + if(popupRequested) DisplayFatalError(buf, 0, 0); // [HGM] crash: this call GameEnds recursively through ExitEvent! Make it a harmless tail recursion. } /* Assumes program was just initialized (initString sent).