Removed last traces of autodetach.
[p5sagit/p5-mst-13.2.git] / ext / threads / threads.xs
index 0e19923..ff2df9d 100755 (executable)
@@ -198,7 +198,9 @@ ithread_mg_free(pTHX_ SV *sv, MAGIC *mg)
             MUTEX_UNLOCK(&thread->mutex);
             Perl_ithread_destruct(aTHX_ thread, "no reference");
        }
-       MUTEX_UNLOCK(&thread->mutex);
+       else {
+           MUTEX_UNLOCK(&thread->mutex);
+       }    
     }
     else {
        MUTEX_UNLOCK(&thread->mutex);
@@ -365,7 +367,6 @@ Perl_ithread_create(pTHX_ SV *obj, char* classname, SV* init_function, SV* param
        MUTEX_INIT(&thread->mutex);
        thread->tid = tid_counter++;
        thread->gimme = GIMME_V;
-       thread->state = (thread->gimme == G_VOID) ? 1 : 0;
 
        /* "Clone" our interpreter into the thread's interpreter
         * This gives thread access to "static data" and code.
@@ -401,6 +402,7 @@ Perl_ithread_create(pTHX_ SV *obj, char* classname, SV* init_function, SV* param
            SvTEMP_off(thread->init_function);
            ptr_table_free(PL_ptr_table);
            PL_ptr_table = NULL;
+           PL_exit_flags |= PERL_EXIT_DESTRUCT_END;
        }
 
        PERL_SET_CONTEXT(aTHX);
@@ -550,6 +552,23 @@ CODE:
 }
 
 void
+ithread_list(char *classname)
+PPCODE:
+{
+  ithread *curr_thread;
+  MUTEX_LOCK(&create_destruct_mutex);
+  curr_thread = threads;
+  while(curr_thread) {
+    PUSHs( ithread_to_SV(aTHX_ NULL, curr_thread, classname, TRUE));
+    curr_thread = curr_thread->next;
+    if(curr_thread == threads)
+      break;
+  }    
+  MUTEX_UNLOCK(&create_destruct_mutex);
+}
+
+
+void
 ithread_self(char *classname)
 CODE:
 {