Menu

#13 fileevent readable failure

open
20. fifo (2)
5
2004-12-11
2004-12-11
Anonymous
No

revision: Memchan 2.2.1

Use of fileevent readable with fifo fails

reference case with memchan
-------------------------------------
package require Memchan

proc isReadable { f } {
if {![eof $f]} {
puts [read $f]
}
}

set fid [memchan]
fileevent $fid readable [list isReadable $fid]

after 5 {puts $::fid "successful" ; seek $::fid 0}
after 500 {set ::DONE 1}

vwait ::DONE
close $fid
----------------------------------------

failure case with fifo
------------------------------------
package require Memchan

proc isReadable { f } {
if {![eof $f]} {
puts [read $f]
}
}

set fid [fifo]
fileevent $fid readable [list isReadable $fid]

after 5 {puts $::fid "fail"}
after 500 {set ::DONE 1}

vwait ::DONE
close $fid

Discussion

  • Pat Thoyts

    Pat Thoyts - 2005-03-08

    Logged In: YES
    user_id=202636

    This looks like the same bug I've been looking into with the
    rechan extension from tclkit. In my case I've been using
    fcopy and finding that fcopying from a channel with no data
    causes a hang. A good example is

    package require Memchan
    set done doing
    set src [fifo]
    #puts $src \x00 ;# any data in the channel fixes the problem.
    set dst [zero]
    proc Complete {args} {set ::done complete}
    proc Timeout {} {set ::done timeout}
    set aid [after 2000 Timeout]
    fcopy $src $dst -command Complete
    vwait ::done
    after cancel $aid
    close $src; close $dst
    puts "Done: $done"

    It looks like a general failure in all the memchan channels.
    Are we missing a flag somewhere? The only setting thats
    apparent to me is that a short read > 0 sets a blocking flag
    in the upper channel layer that seems to cause the next call
    to the WatchProc to have mask be non-zero. This is
    sufficient to set the timer and ensure we get another
    fileevent raised with the eof set.

     
  • Nobody/Anonymous

    Sourceforge.. Reposted it :)

     
MongoDB Logo MongoDB