Bug 198634: we need to implement PR_DetachThread on the platforms that
authorwtc%netscape.com
Thu, 10 Apr 2003 02:22:44 +0000
changeset 2797 29a19598d555a735b634c57b22261c6cc0d388ab
parent 2796 43af32ccaeaa4d9e7e4908ae738aae7da71d23ab
child 2798 0b1ff2f255f1a24498043dd28280c697d3a71915
push idunknown
push userunknown
push dateunknown
bugs198634
Bug 198634: we need to implement PR_DetachThread on the platforms that don't have a way to detach the foreign threads automatically when they terminate (e.g., OS/2). The patch is contributed by Michael Kaply <mkaply@us.ibm.com>.
pr/src/threads/combined/pruthr.c
--- a/pr/src/threads/combined/pruthr.c
+++ b/pr/src/threads/combined/pruthr.c
@@ -1504,16 +1504,28 @@ PR_IMPLEMENT(PRThread*) PR_AttachThread(
 #ifdef XP_MAC
 #pragma unused( type, priority, stack )
 #endif
     return PR_GetCurrentThread();
 }
 
 PR_IMPLEMENT(void) PR_DetachThread(void)
 {
+    /*
+     * On IRIX and Windows, foreign threads are detached when
+     * they terminate.
+     */
+#if !defined(IRIX) && !defined(WIN32)
+    PRThread *me;
+    if (_pr_initialized) {
+        me = _MD_GET_ATTACHED_THREAD();
+        if ((me != NULL) && (me->flags & _PR_ATTACHED))
+            _PRI_DetachThread();
+    }
+#endif
 }
 
 void _PRI_DetachThread(void)
 {
     PRThread *me = _PR_MD_CURRENT_THREAD();
 
 	if (me->flags & _PR_PRIMORDIAL) {
 		/*