]> git.sesse.net Git - stockfish/commitdiff
Merge branch 'master' of ssh://free2.projectlocker.com/sf
authorTord Romstad <tord@cm-84.215.101.133.getinternet.no>
Sun, 24 Jan 2010 15:09:54 +0000 (16:09 +0100)
committerTord Romstad <tord@cm-84.215.101.133.getinternet.no>
Sun, 24 Jan 2010 15:09:54 +0000 (16:09 +0100)
1  2 
src/search.cpp

diff --combined src/search.cpp
index 71b974b677d893f3325734f0de639de984c9e2b5,5d2e5175b052bdc35fc5019bdf45dfa39bbd9860..df74d580ec2b954cd346b310438a976b9819bbca
@@@ -442,10 -442,6 +442,10 @@@ bool think(const Position& pos, bool in
    {
        ActiveThreads = newActiveThreads;
        init_eval(ActiveThreads);
 +      // HACK: init_eval() destroys the static castleRightsMask[] array in the
 +      // Position class. The below line repairs the damage.
 +      Position p(pos.to_fen());
 +      assert(pos.is_ok());
    }
  
    // Wake up sleeping threads
  void init_threads() {
  
    volatile int i;
+   bool ok;
  
  #if !defined(_MSC_VER)
    pthread_t pthread[1];
    for (i = 1; i < THREAD_MAX; i++)
    {
  #if !defined(_MSC_VER)
-       pthread_create(pthread, NULL, init_thread, (void*)(&i));
+       ok = (pthread_create(pthread, NULL, init_thread, (void*)(&i)) == 0);
  #else
        DWORD iID[1];
-       CreateThread(NULL, 0, init_thread, (LPVOID)(&i), 0, iID);
+       ok = (CreateThread(NULL, 0, init_thread, (LPVOID)(&i), 0, iID) != NULL);
  #endif
  
+       if (!ok)
+       {
+           cout << "Failed to create thread number " << i << endl;
+           Application::exit_with_failure();
+       }
        // Wait until the thread has finished launching
        while (!Threads[i].running);
    }
@@@ -2796,6 -2799,8 +2803,8 @@@ namespace 
        // If this thread has been assigned work, launch a search
        if (Threads[threadID].workIsWaiting)
        {
+           assert(!Threads[threadID].idle);
            Threads[threadID].workIsWaiting = false;
            if (Threads[threadID].splitPoint->pvNode)
                sp_search_pv(Threads[threadID].splitPoint, threadID);