]> git.saurik.com Git - wxWidgets.git/commitdiff
fixed a race condition resulting in returning incorrect thread exit code
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 3 Apr 2002 00:13:48 +0000 (00:13 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 3 Apr 2002 00:13:48 +0000 (00:13 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14917 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/thread.cpp

index 7a42d2e60e0fceddac1372020a5fef241877f7ad..c516a161d7b172e6e263d9aec6d456374fc15098 100644 (file)
@@ -1135,12 +1135,18 @@ wxThreadError wxThread::Delete(ExitCode *pRc)
         }
     }
 
-    if ( !::GetExitCodeThread(hThread, (LPDWORD)&rc) )
+    // although the thread might be already in the EXITED state it might not
+    // have terminated yet and so we are not sure that it has actually
+    // terminated if the "if" above hadn't been taken
+    do
     {
-        wxLogLastError(wxT("GetExitCodeThread"));
+        if ( !::GetExitCodeThread(hThread, (LPDWORD)&rc) )
+        {
+            wxLogLastError(wxT("GetExitCodeThread"));
 
-        rc = (ExitCode)-1;
-    }
+            rc = (ExitCode)-1;
+        }
+    } while ( (DWORD)rc == STILL_ACTIVE );
 
     if ( IsDetached() )
     {
@@ -1151,9 +1157,6 @@ wxThreadError wxThread::Delete(ExitCode *pRc)
         delete this;
     }
 
-    wxASSERT_MSG( (DWORD)rc != STILL_ACTIVE,
-                  wxT("thread must be already terminated.") );
-
     if ( pRc )
         *pRc = rc;