]> git.sesse.net Git - stockfish/commitdiff
Call wait_for_search_finished() only when quitting
authorMarco Costalba <mcostalba@gmail.com>
Mon, 26 Mar 2012 17:35:23 +0000 (18:35 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Mon, 26 Mar 2012 17:44:30 +0000 (18:44 +0100)
When quitting we should avoid RootPosition to be
destroyed while threads are still running, leading
to a crash. In case of a "stop" or "ponderhit"
command there is no need for the UI thread to wait.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/uci.cpp

index 987da9c1f879ec7304184092ffa14028c5dab396..0057881b010a812404e1e7d94c87166805f8a007 100644 (file)
@@ -69,7 +69,9 @@ void uci_loop() {
       if (token == "quit" || token == "stop")
       {
           Search::Signals.stop = true;
       if (token == "quit" || token == "stop")
       {
           Search::Signals.stop = true;
-          Threads.wait_for_search_finished(); // Cannot quit while threads are running
+
+          if (token == "quit") // Cannot quit while threads are still running
+              Threads.wait_for_search_finished();
       }
 
       else if (token == "ponderhit")
       }
 
       else if (token == "ponderhit")
@@ -80,10 +82,7 @@ void uci_loop() {
           Search::Limits.ponder = false;
 
           if (Search::Signals.stopOnPonderhit)
           Search::Limits.ponder = false;
 
           if (Search::Signals.stopOnPonderhit)
-          {
               Search::Signals.stop = true;
               Search::Signals.stop = true;
-              Threads.wait_for_search_finished();
-          }
       }
 
       else if (token == "go")
       }
 
       else if (token == "go")