Changeset 11170


Ignore:
Timestamp:
Oct 18, 2008, 11:51:05 PM (11 years ago)
Author:
gb
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/thread_manager.c

    r11149 r11170  
    12191219#ifndef WINDOWS
    12201220  tcr->shutdown_count = PTHREAD_DESTRUCTOR_ITERATIONS;
     1221#else
     1222  tcr->shutdown_count = 1;
    12211223#endif
    12221224  return tcr;
     
    12261228shutdown_thread_tcr(void *arg)
    12271229{
    1228   TCR *tcr = TCR_FROM_TSD(arg);
     1230  TCR *tcr = TCR_FROM_TSD(arg),*current=get_tcr(0);
    12291231
    12301232  area *vs, *ts, *cs;
    12311233  void *termination_semaphore;
    12321234 
     1235  if (current == NULL) {
     1236    current = tcr;
     1237  }
     1238
    12331239  if (--(tcr->shutdown_count) == 0) {
    12341240    if (tcr->flags & (1<<TCR_FLAG_BIT_FOREIGN)) {
     
    12431249    darwin_exception_cleanup(tcr);
    12441250#endif
    1245     LOCK(lisp_global(TCR_AREA_LOCK),tcr);
     1251    LOCK(lisp_global(TCR_AREA_LOCK),current);
    12461252    vs = tcr->vs_area;
    12471253    tcr->vs_area = NULL;
     
    12801286    tcr->io_datum = NULL;
    12811287#endif
    1282     UNLOCK(lisp_global(TCR_AREA_LOCK),tcr);
     1288    UNLOCK(lisp_global(TCR_AREA_LOCK),current);
    12831289    if (termination_semaphore) {
    12841290      SEM_RAISE(termination_semaphore);
     
    19081914         mark the TCR as dead and kill thw Windows thread. */
    19091915      tcr->osid = 0;
    1910       if (!TerminateThread(osid, 0)) {
     1916      if (!TerminateThread((HANDLE)osid, 0)) {
    19111917        result = false;
     1918      } else {
     1919        shutdown_thread_tcr(tcr);
    19121920      }
    19131921#else
Note: See TracChangeset for help on using the changeset viewer.