From a378d97dc9d9eadaef00a9f01816948db5f3a796 Mon Sep 17 00:00:00 2001 From: rpj Date: Tue, 4 Jan 2000 10:19:28 +0000 Subject: Main changes (see ChangeLog diff for details and attributions):- - asynchronous cancellation added - attempt to hide internal exceptions from applications - kernel32 load/free problem fixed - new tests - changes only to comments in some tests --- sync.c | 58 +++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 19 deletions(-) (limited to 'sync.c') diff --git a/sync.c b/sync.c index 06dffd9..f2d1b06 100644 --- a/sync.c +++ b/sync.c @@ -124,14 +124,32 @@ pthread_join (pthread_t thread, void **value_ptr) } else { +#if 0 DWORD stat; stat = WaitForSingleObject (thread->threadH, INFINITE); +#else + /* + * Pthread_join is a cancelation point. + * If we are cancelled then our target thread must not be + * detached (destroyed). This is guarranteed because + * pthreadCancelableWait will not return if we + * are cancelled. + */ + result = pthreadCancelableWait(thread->threadH); +#endif + + if ( +#if 0 + stat == WAIT_OBJECT_0 +#else + result == 0 +#endif + ) + { #if ! defined (__MINGW32__) || defined (__MSVCRT__) - if (stat == WAIT_OBJECT_0) - { if (value_ptr != NULL && !GetExitCodeThread (thread->threadH, (LPDWORD) value_ptr)) { @@ -145,31 +163,33 @@ pthread_join (pthread_t thread, void **value_ptr) */ _pthread_threadDestroy (thread); } - } - else - { - result = ESRCH; - } #else /* __MINGW32__ && ! __MSVCRT__ */ - /* - * If using CRTDLL, the thread may have exited, and endthread - * will have closed the handle. - */ - if (value_ptr != NULL) - *value_ptr = self->exitStatus; + /* + * If using CRTDLL, the thread may have exited, and endthread + * will have closed the handle. + */ + if (value_ptr != NULL) + { + *value_ptr = self->exitStatus; + } - /* - * The result of making multiple simultaneous calls to - * pthread_join() specifying the same target is undefined. - */ - _pthread_threadDestroy (thread); + /* + * The result of making multiple simultaneous calls to + * pthread_join() specifying the same target is undefined. + */ + _pthread_threadDestroy (thread); #endif /* __MINGW32__ && ! __MSVCRT__ */ + + } + else + { + result = ESRCH; + } } return (result); } /* pthread_join */ - -- cgit v1.2.3