Tcl Source Code

View Ticket
Login
Ticket UUID: 1512225
Title: tpool::wait and tpool::cancel set wrong value to variable
Type: Bug Version: obsolete: 8.4.13
Submitter: nyademo Created on: 2006-06-25 18:38:22
Subsystem: 80. Thread Package Assigned To: vasiljevic
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2007-06-30 22:31:16
Resolution: Fixed Closed By: vasiljevic
    Closed on: 2007-06-30 15:31:16
Description:
tpool::wait and tpool::cancel set wrong value to
optional variable.


Windows2000
ActiveTcl8.4.13
Thread2.6.3 compiled by VC6


Sample code for tpool::wait
-------------------------------------------------------
set tp [tpool::create -maxworkers 1]
for {set i 1} {$i < 10} {incr i} {
puts [tpool::post -nowait $tp [subst {
puts $i:start
after 5000
puts $i:end
}]]
}
puts [tpool::wait $tp {4 5 6} waiting]:DONE
if {[llength $waiting] != 2} {
error "waiting is $waiting"
}


In this code, only one worker thread is worked.
So posted jobs are eval one by one.
When the 4 job is finishing, tpool::wait returns from 
event loop, and returns number 4, 
and should set a list of waiting jobs (5 and 6) 
to "waiting" variable.
But "waiting" variable is empty list.


Sample code for tpool::wait
-------------------------------------------------------
set tp [tpool::create -maxworkers 1]
for {set i 1} {$i < 10} {incr i} {
puts [tpool::post -nowait $tp [subst {
puts $i:start
after 1000
puts $i:end
}]]
}
after 5000
# jobs 1,2,3 was already done here
tpool::cancel $tp {1 2 3} uncanceled
if {$uncanceled ne {1 2 3}} {
# may be $uncanceled is {1 1 1 2 2 2 3 3 3}
error "uncanceled is $uncanceled"
}


In this code, only one worker thread is worked.
So posted jobs are eval one by one.
After The 1, 2 and 3 jobs are finished, tpool::cancel 
is called. So 1,2,3 jobs can't be canceled.
tpool::cancel returns empty list and should set a list
of uncanceled jobs (1,2 and 3) to "uncanceled" variable.
But "uncanceled" variable is {1 1 1 2 2 2 3 3 3} 
in this case.


There isn't a test, so I have no confidence 
in detail of specifications... 
But I try to make a pach. see also that.

thanks.
User Comments: vasiljevic added on 2007-06-30 22:29:52:
Logged In: YES 
user_id=95086
Originator: NO

Great work! Many thanks for the patch
and your time. I have added this into the
CVS head. Please checkout and see if
all is fine. Your test programs work as
expected now. The fixed will appear first
in 2.6.6 version.

Cheers,
Zoran

nyademo added on 2006-06-26 01:38:22:

File Added - 182941: threadPoolCmd.c.patch

Attachments: