Change 28399 by [EMAIL PROTECTED] on 2006/06/17 16:39:53 dont warn at exit of detatched threads still running
Affected files ... ... //depot/perl/ext/threads/t/blocks.t#3 edit ... //depot/perl/ext/threads/threads.xs#110 edit Differences ... ==== //depot/perl/ext/threads/t/blocks.t#3 (text) ==== Index: perl/ext/threads/t/blocks.t --- perl/ext/threads/t/blocks.t#2~28355~ 2006-06-06 04:02:14.000000000 -0700 +++ perl/ext/threads/t/blocks.t 2006-06-17 09:39:53.000000000 -0700 @@ -95,4 +95,8 @@ ok($mthr->join() == 42, 'Main join'); ok($bthr->join() == 42, 'BEGIN join'); -# EOF +# make sure a still-running detached thread doesn't give a warning on exit + +# *** add new tests above this one +threads->create(sub { 1 while 1 })->detach(); +# *** add new tests above this one ==== //depot/perl/ext/threads/threads.xs#110 (xtext) ==== Index: perl/ext/threads/threads.xs --- perl/ext/threads/threads.xs#109~28355~ 2006-06-06 04:02:14.000000000 -0700 +++ perl/ext/threads/threads.xs 2006-06-17 09:39:53.000000000 -0700 @@ -82,6 +82,7 @@ static UV tid_counter = 0; static IV active_threads = 0; +static IV joinable_threads = 0; #ifdef THREAD_CREATE_NEEDS_STACK static IV default_stack_size = THREAD_CREATE_NEEDS_STACK; #else @@ -194,9 +195,9 @@ { int veto_cleanup = 0; MUTEX_LOCK(&create_destruct_mutex); - if ((aTHX == PL_curinterp) && (active_threads != 1)) { + if ((aTHX == PL_curinterp) && (joinable_threads != 1)) { if (ckWARN_d(WARN_THREADS)) { - Perl_warn(aTHX_ "A thread exited while %" IVdf " threads were running", active_threads); + Perl_warn(aTHX_ "A thread exited while %" IVdf " threads were running", joinable_threads); } veto_cleanup = 1; } @@ -394,6 +395,9 @@ MUTEX_LOCK(&create_destruct_mutex); active_threads--; + if (!cleanup) { + joinable_threads--; + } MUTEX_UNLOCK(&create_destruct_mutex); #ifdef WIN32 @@ -654,6 +658,7 @@ } active_threads++; + joinable_threads++; MUTEX_UNLOCK(&create_destruct_mutex); sv_2mortal(params); @@ -970,6 +975,11 @@ if (cleanup) S_ithread_destruct(aTHX_ thread); + else { + MUTEX_LOCK(&create_destruct_mutex); + joinable_threads--; + MUTEX_UNLOCK(&create_destruct_mutex); + } void @@ -1176,6 +1186,7 @@ # endif active_threads++; + joinable_threads++; S_ithread_set(aTHX_ thread); MUTEX_UNLOCK(&create_destruct_mutex); End of Patch.