[Openmcl-cvs-notifications] r11170 - /trunk/source/lisp-kernel/thread_manager.c

gb at clozure.com gb at clozure.com
Sat Oct 18 19:51:05 EDT 2008


Author: gb
Date: Sat Oct 18 19:51:05 2008
New Revision: 11170

Log:
Set tcr->shutdown_count to 1 in new_tcr() on Windows.
shutdown_thread_tcr(): use current tcr for locking (not necessarily the
tcr being shutdown.)
In windows kill_tcr(), have the caller call shutdown_thread_tcr(), unless
and until we can force the target to clean up after itself.

Modified:
    trunk/source/lisp-kernel/thread_manager.c

Modified: trunk/source/lisp-kernel/thread_manager.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/source/lisp-kernel/thread_manager.c (original)
+++ trunk/source/lisp-kernel/thread_manager.c Sat Oct 18 19:51:05 2008
@@ -1218,6 +1218,8 @@
   TCR_INTERRUPT_LEVEL(tcr) =3D (LispObj) (-1<<fixnum_shift);
 #ifndef WINDOWS
   tcr->shutdown_count =3D PTHREAD_DESTRUCTOR_ITERATIONS;
+#else
+  tcr->shutdown_count =3D 1;
 #endif
   return tcr;
 }
@@ -1225,11 +1227,15 @@
 void
 shutdown_thread_tcr(void *arg)
 {
-  TCR *tcr =3D TCR_FROM_TSD(arg);
+  TCR *tcr =3D TCR_FROM_TSD(arg),*current=3Dget_tcr(0);
 =

   area *vs, *ts, *cs;
   void *termination_semaphore;
   =

+  if (current =3D=3D NULL) {
+    current =3D tcr;
+  }
+
   if (--(tcr->shutdown_count) =3D=3D 0) {
     if (tcr->flags & (1<<TCR_FLAG_BIT_FOREIGN)) {
       LispObj callback_macptr =3D nrs_FOREIGN_THREAD_CONTROL.vcell,
@@ -1242,7 +1248,7 @@
 #ifdef DARWIN
     darwin_exception_cleanup(tcr);
 #endif
-    LOCK(lisp_global(TCR_AREA_LOCK),tcr);
+    LOCK(lisp_global(TCR_AREA_LOCK),current);
     vs =3D tcr->vs_area;
     tcr->vs_area =3D NULL;
     ts =3D tcr->ts_area;
@@ -1279,7 +1285,7 @@
     CloseHandle((HANDLE)tcr->io_datum);
     tcr->io_datum =3D NULL;
 #endif
-    UNLOCK(lisp_global(TCR_AREA_LOCK),tcr);
+    UNLOCK(lisp_global(TCR_AREA_LOCK),current);
     if (termination_semaphore) {
       SEM_RAISE(termination_semaphore);
     }
@@ -1907,8 +1913,10 @@
          forcing the thread to run quit_handler().  For now,
          mark the TCR as dead and kill thw Windows thread. */
       tcr->osid =3D 0;
-      if (!TerminateThread(osid, 0)) {
+      if (!TerminateThread((HANDLE)osid, 0)) {
         result =3D false;
+      } else {
+        shutdown_thread_tcr(tcr);
       }
 #else
       if (pthread_kill((pthread_t)osid,SIGQUIT)) {



More information about the Openmcl-cvs-notifications mailing list