commit 168b125cfb12364ae9746f175f1a8a7b6fdd43fc
Author: ktietz70 <ktietz70@4407c894-4637-0410-b4f5-ada5f102cad1>
Date: Mon Dec 6 15:32:52 2010 +0000
Fix some test-cases
git-svn-id: svn://svn.code.sf.net/p/mingw-w64/code/experimental@3845 4407c894-4637-0410-b4f5-ada5f102cad1
diff --git a/winpthreads/src/thread.c b/winpthreads/src/thread.c
index 113e024..1d8cbc9 100644
--- a/winpthreads/src/thread.c
+++ b/winpthreads/src/thread.c
@@ -708,14 +739,23 @@ int pthread_join(pthread_t t, void **res)
int _pthread_tryjoin(pthread_t t, void **res)
{
+ DWORD dwFlags;
struct _pthread_v *tv = t;
+
+ if (!tv || tv->h == NULL || tv->h == INVALID_HANDLE_VALUE || !GetHandleInformation(tv->h, &dwFlags))
+ return ESRCH;
- CHECK_THREAD(tv);
+ if ((tv->p_state & PTHREAD_CREATE_DETACHED) != 0)
+ return EINVAL;
if (pthread_equal(pthread_self(), t)) return EDEADLK;
pthread_testcancel();
- if(WaitForSingleObject(tv->h, 0))return EBUSY;
+ if(tv->ended == 0 && WaitForSingleObject(tv->h, 0))
+ {
+ if (tv->ended == 0);
+ return EBUSY;
+ }
CloseHandle(tv->h);
/* Obtain return value */