From: H.G. Muller Date: Thu, 8 Mar 2012 08:56:51 +0000 (+0100) Subject: Fix seek-graph race condition X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=3b4fbf5b20f6eba7e5f45e8ba87958ecfe0cbd14;p=xboard.git Fix seek-graph race condition When a game started just after the user requested a seek graph, so that the game start message would be received between sending 'sought' and receiving the seek-ad list, an empty graph would pop up on the prompt, and it was not possible to take it down, because the gameMode was no longer IcsIdle. This patch cancels a sought command on receiving a board of your own game to prevent this situation. In addition the system is made more robust by always accepting a left-click as pop-down request, even when the seek graph cannot be up, when it is up anyway. --- diff --git a/backend.c b/backend.c index f00997e..803bb71 100644 --- a/backend.c +++ b/backend.c @@ -2616,6 +2616,13 @@ SeekGraphClick (ClickType click, int x, int y, int moving) { static int lastDown = 0, displayed = 0, lastSecond; if(y < 0) return FALSE; + if(!(appData.seekGraph && appData.icsActive && loggedOn && + (gameMode == BeginningOfGame || gameMode == IcsIdle))) { + if(!seekGraphUp) return FALSE; + seekGraphUp = FALSE; // seek graph is up when it shouldn't be: take it down + DrawPosition(TRUE, NULL); + return TRUE; + } if(!seekGraphUp) { // initiate cration of seek graph by requesting seek-ad list if(click == Release || moving) return FALSE; nrOfSeekAds = 0; @@ -3562,7 +3569,7 @@ read_from_ics (InputSourceRef isr, VOIDSTAR closure, char *data, int count, int if (looking_at(buf, &i, "% ") || ((started == STARTED_MOVES || started == STARTED_MOVES_NOHIDE) && looking_at(buf, &i, "}*"))) { char *bookHit = NULL; // [HGM] book - if(soughtPending) { // [HGM] seekgraph: on ICC sought-list has no termination line + if(soughtPending && nrOfSeekAds) { // [HGM] seekgraph: on ICC sought-list has no termination line soughtPending = FALSE; seekGraphUp = TRUE; DrawSeekGraph(); @@ -4210,6 +4217,7 @@ ParseBoard12 (char *string) newGameMode = ((relation == RELATION_PLAYING_MYMOVE) == (to_play == 'W')) ? IcsPlayingWhite : IcsPlayingBlack; + soughtPending =FALSE; // [HGM] seekgraph: solve race condition break; case RELATION_EXAMINING: newGameMode = IcsExamining; @@ -6829,11 +6837,7 @@ LeftClick (ClickType clickType, int xPix, int yPix) char promoChoice = NULLCHAR; ChessSquare piece; - if(appData.seekGraph && appData.icsActive && loggedOn && - (gameMode == BeginningOfGame || gameMode == IcsIdle)) { - SeekGraphClick(clickType, xPix, yPix, 0); - return; - } + if(SeekGraphClick(clickType, xPix, yPix, 0)) return; if (clickType == Press) ErrorPopDown();