Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2001-04-03
07:45 • Ticket [218003ffff] "readable" fileevents behave inaccurately on Windo... artifact: bedd810d8e user: dgp
2000-10-26
08:12 • Closed ticket [218003ffff]. artifact: 736650a14c user: welch
00:51 • New ticket [218003ffff]. artifact: 00368836b0 user: nobody

"readable" fileevents behave inaccurately on Windows

Closed / Fixed218003ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:51:52
OriginalBugID: 700 Bug
Version: 8.0.3
SubmitDate: '1998-10-09'
LastModified: '1999-08-09'
Severity: MED
Status: Closed
Submitter: suresh
ChangedBy: redman
OS: All
OSVersion: NA
Machine: NA
FixedDate: '2000-10-25'
FixedInVersion: 8.2b2
ClosedDate: '1999-08-09'


Basically there appears to be a bug in the handling of events via the "fileevent" command on Windows.  The bug is that on Windows, fileevents come in at unpredictable times and inconsistent with the same script that runs on UNIX.   See the script below and the produced output on both Windows and UNIX.

See the following script

=======================================
# fileevent-bug.tcl
set hosts {pop hippo cerridwen}
proc myProc {f host hostDone} {
    if {![eof $f]} {
puts "0 [clock sec] $host $f -- readable"
read $f
    } else {
puts "1 [clock sec] $host $f -- eof"
set ::$hostDone $host
    }
}
set sleepTime 0
foreach host $hosts {
    set hostFiles($host) [open "| rsh $host sleep [incr sleepTime 10]"]
    puts "$host $hostFiles($host)"
}
set allHostsDone 0
foreach host [array name hostFiles] {
    fileevent $hostFiles($host) readable  [list myProc $hostFiles($host) $host hostDone]
}
while {[array size hostFiles]} {
    vwait hostDone
    puts "2 [clock sec] $hostDone $hostFiles($hostDone) -- hostdone"
    catch {close $hostFiles($hostDone)} result
    unset hostFiles($hostDone)
}
=======================================

If you run this script on Windows, you will get the following output:

=======================================
[c:\temp]tclsh80 z:\fileevent-bug.tcl
pop file160
hippo file76
cerridwen file24
0 907963252 pop file160 -- readable
0 907963262 cerridwen file24 -- readable
0 907963284 hippo file76 -- readable
1 907963284 pop file160 -- eof
2 907963284 pop file160 -- hostdone
1 907963284 cerridwen file24 -- eof
2 907963284 cerridwen file24 -- hostdone
1 907963284 hippo file76 -- eof
2 907963284 hippo file76 -- hostdone
=======================================

However, on UNIX you get:

=======================================
pop> tcls8.0h fileevent-bug.tcl 
pop file3
hippo file5
cerridwen file8
0 907963245 pop file3 -- readable
1 907963245 pop file3 -- eof
2 907963245 pop file3 -- hostdone
0 907963255 hippo file5 -- readable
1 907963255 hippo file5 -- eof
2 907963255 hippo file5 -- hostdone
0 907963266 cerridwen file8 -- readable
1 907963266 cerridwen file8 -- eof
2 907963266 cerridwen file8 -- hostdone
=======================================



This bug was discovered during development of TclPro nightly build script.  The script kicks off UNIX hosts in parallel from Windows via the Windows RSH.EXE command;  if you look at the build output e-mail, you see that all the UNIX builds finish exactly at the same time (to the second), which is unlikely and is due to "fileevent" waiting for all hosts to "remove" themselves from the "fileevent" list.  (suresh:981009)
welch Closed ticket [218003ffff]. [History diff]2000-10-26 08:12:11
dgp Ticket [218003ffff]: 4 changes [History diff]2001-04-03 07:45:27
Log in (anonymous is fine) to add a comment.