summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/threads/t/list.t14
-rwxr-xr-xext/threads/threads.xs9
2 files changed, 12 insertions, 11 deletions
diff --git a/ext/threads/t/list.t b/ext/threads/t/list.t
index f0995a1bc4..60bf20912d 100644
--- a/ext/threads/t/list.t
+++ b/ext/threads/t/list.t
@@ -34,21 +34,21 @@ sub ok {
return $ok;
}
+ok(2, scalar @{[threads->list]} == 0);
-ok(2, threads->self == (threads->list)[0]);
threads->create(sub {})->join();
-ok(3, scalar @{[threads->list]} == 1);
+ok(3, scalar @{[threads->list]} == 0);
my $thread = threads->create(sub {});
-ok(4, scalar @{[threads->list]} == 2);
+ok(4, scalar @{[threads->list]} == 1);
$thread->join();
-ok(5, scalar @{[threads->list]} == 1);
+ok(5, scalar @{[threads->list]} == 0);
-$thread = threads->create(sub { ok(6, threads->self == (threads->list)[1])});
+$thread = threads->create(sub { ok(6, threads->self == (threads->list)[0])});
threads->yield; # help out non-preemptive thread implementations
sleep 1;
-ok(7, $thread == (threads->list)[1]);
+ok(7, $thread == (threads->list)[0]);
$thread->join();
-ok(8, scalar @{[threads->list]} == 1);
+ok(8, scalar @{[threads->list]} == 0);
diff --git a/ext/threads/threads.xs b/ext/threads/threads.xs
index 59e3597aad..88aaf0eaf7 100755
--- a/ext/threads/threads.xs
+++ b/ext/threads/threads.xs
@@ -561,15 +561,16 @@ PPCODE:
ithread *curr_thread;
MUTEX_LOCK(&create_destruct_mutex);
curr_thread = threads;
- PUSHs( sv_2mortal(ithread_to_SV(aTHX_ NULL, curr_thread, classname, TRUE)));
+ if(curr_thread->tid != 0)
+ PUSHs( sv_2mortal(ithread_to_SV(aTHX_ NULL, curr_thread, classname, TRUE)));
while(curr_thread) {
curr_thread = curr_thread->next;
if(curr_thread == threads)
break;
if(curr_thread->state & PERL_ITHR_DETACHED ||
- curr_thread->state & PERL_ITHR_JOINED)
- continue;
- PUSHs( sv_2mortal(ithread_to_SV(aTHX_ NULL, curr_thread, classname, TRUE)));
+ curr_thread->state & PERL_ITHR_JOINED)
+ continue;
+ PUSHs( sv_2mortal(ithread_to_SV(aTHX_ NULL, curr_thread, classname, TRUE)));
}
MUTEX_UNLOCK(&create_destruct_mutex);
}