summaryrefslogtreecommitdiff
path: root/sync.c
diff options
context:
space:
mode:
authorrpj <rpj>2000-01-04 10:19:28 +0000
committerrpj <rpj>2000-01-04 10:19:28 +0000
commita378d97dc9d9eadaef00a9f01816948db5f3a796 (patch)
tree654435cc0a85156c2a9b4793ab7d8e0da8424e32 /sync.c
parent27d833666dfd72cc6e74c3900d3e8e66321bea3a (diff)
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
Diffstat (limited to 'sync.c')
-rw-r--r--sync.c58
1 files changed, 39 insertions, 19 deletions
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 */
-