From: H.G.Muller Date: Wed, 30 Nov 2016 08:02:50 +0000 (+0100) Subject: Treat 'quit', 'force' and '?' commands immediately X-Git-Tag: v4.0~51 X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=85a82d8e5887b236ac8c6bad257301b4d30b948d;p=uci2wb.git Treat 'quit', 'force' and '?' commands immediately The blocking of input during thinking made it also insensitive to 'quit'. This would cause hanging engine processes when the GUI was closed and would kill the adapter because it did not respond to 'quit' in time. The Sync() call that waits for the engine's 'bestmove' is now deferred until after reading input (executed conditionally through a 'think' flag, so that it only happens during thinking), so that we can peek at the first command that arrives during thinking. If it is one of the 'immediate' commands (?, quit or force), a 'stop' command is sent to the engine before we start waiting for the 'bestmove', which then never should take long. Draw offers could potentially arrive during thinking as well, interefering with this mechanism by eclipsing a following ?/quit/force. As these would just set the drawOffer flag for processing during the next move, these are now fully processed immediately. --- diff --git a/UCI2WB.c b/UCI2WB.c index c13ea34..2971c3f 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -398,7 +398,7 @@ GUI2Engine() char line[256], command[256], *p, *q, *r, mySide, searching = 0; while(1) { - int i, x; + int i, x, think=0; if((computer == stm || computer == ANALYZE && !searching) && !suspended) { DPRINT("# start search\n"); @@ -412,13 +412,18 @@ GUI2Engine() for(i=1; i