$OpenBSD: patch-mozilla_nsprpub_pr_src_misc_prinit_c,v 1.1.1.1 2004/01/29 21:57:53 pvalchev Exp $
--- mozilla/nsprpub/pr/src/misc/prinit.c.orig	2004-01-06 22:06:01.000000000 -0500
+++ mozilla/nsprpub/pr/src/misc/prinit.c	2004-01-06 22:08:37.000000000 -0500
@@ -430,6 +430,12 @@ PR_IMPLEMENT(PRStatus) PR_Cleanup()
 	    _PR_LogCleanup();
 
         /*
+         * accesses the current thread
+         */
+        _PR_CleanupNet();
+        _PR_CleanupIO();
+
+        /*
          * This part should look like the end of _PR_NativeRunThread
          * and _PR_UserRunThread.
          */
@@ -441,6 +447,7 @@ PR_IMPLEMENT(PRStatus) PR_Cleanup()
             PR_DELETE(me->stack);
             PR_DELETE(me);
         }
+        _PR_MD_SET_CURRENT_THREAD(NULL);
 
         /*
          * XXX: We are freeing the heap memory here so that Purify won't
@@ -449,8 +456,6 @@ PR_IMPLEMENT(PRStatus) PR_Cleanup()
          * Ideally, for each _PR_InitXXX(), there should be a corresponding
          * _PR_XXXCleanup() that we can call here.
          */
-        _PR_CleanupNet();
-        _PR_CleanupIO();
 #ifdef WINNT
         _PR_CleanupCPUs();
 #endif
