Menu

#42 udpInput() signals false EOF

v1.x
closed-fixed
nobody
None
5
2014-08-24
2014-07-30
Don Porter
No

When a Tcl_DriverInputProc() returns the value 0,
the core I/O parts of Tcl take that to mean a signal
of EOF on the channel. udpInput() is returning 0
in several places when it does not intend that meaning.

See http://core.tcl.tk/tcl/tktview/1ff0660e6e
for a rundown of the corrections that are needed.

The Tcl 8.5.16 release candidate contains revisions
where the Tcl I/O core has started believing the
claims sent back from channel drivers. If a driver
says it's reached EOF, the I/O core won't call its
input proc anymore. As things currently stand, these
bugs will have to be fixed for tcludp to work with
Tcl 8.5.16.

For the sake of the existing deployed extensions,
I'll be looking into what accommodations might be
offered before 8.5.16 release, but the sooner the
bugs in extensions are fixed, the better.

Discussion

  • Don Porter

    Don Porter - 2014-08-11

    I had to do some guess work on this.
    May need review and revision.

    But on the demo script I have, this patch
    solves the problem with Tcl 8.5.16 and Tcl 8.6.2.

     
  • Huub Eikens

    Huub Eikens - 2014-08-18

    Don,

    I'm abroad for the last three weeks (and 1 week to come) with limited email access hence my late response. Since I don't have my tclupd development environment with me, I cannot properly test your patch. I can commit the change though if you (or someone else) can confirm that this patch is correct.

    Regards,

    Huub

     
  • Don Porter

    Don Porter - 2014-08-18

    I'd greatly prefer review by an independent set
    of eyes -- ideally those of someone invested in
    the success of tcludp.

    As things stand, the Tcl 8.5.16 release will
    accommodate existing tcludp releases. Tcl 8.6.2
    will not, and I expect tcludp packages to fail with
    it unless this patch, or some revision of it, is
    accepted and a corrected tcludp release restores
    things.

     
  • Huub Eikens

    Huub Eikens - 2014-08-19

    I'll take a look at it when I'm back.

     
  • Huub Eikens

    Huub Eikens - 2014-08-21

    I am unable to reproduce the problem. What I've done so far is:
    1. Downloaded and build the tcl 8.5.15 version using the link http://prdownloads.sourceforge.net/tcl/tcl861-src.zip
    2. Build the tcludp package (without your patch) against it.
    3. Run the following script as described in the ticket (https://groups.google.com/forum/#!topic/comp.lang.tcl/sRr678PXFfM) :

    package require udp 
    set host localhost; set port 53530
    
    ## udp sender 
    proc udp_puts {host port} { 
        set s [udp_open] 
        fconfigure $s -remote [list $host $port] -buffering none -translation binary 
        puts $s "Hello, World" 
        close $s 
    }
    
    # A simple UDP server 
    proc udpEventHandler {sock} { 
        set pkt [read $sock] 
        set peer [fconfigure $sock -peer] 
        puts "$peer: [string length $pkt] {$pkt}" 
        return 
    } 
    proc udp_listen {port} { 
        set srv [udp_open $port] 
        fconfigure $srv -buffering none -translation binary 
        fileevent $srv readable [list ::udpEventHandler $srv] 
        puts "Listening on udp port: [fconfigure $srv -myport]" 
        return $srv 
    } 
    set sock [udp_listen $port]
    
    proc sendMessages {} {
        global host
        global port
        udp_puts $host $port
        after 1000 sendMessages
    }
    sendMessages
    vwait forever
    

    The output I get is:
    127.0.0.1 58965: 12 {Hello, World}
    127.0.0.1 58965: 1 {
    }
    127.0.0.1 39474: 12 {Hello, World}
    127.0.0.1 39474: 1 {
    }
    127.0.0.1 49044: 12 {Hello, World}
    127.0.0.1 49044: 1 {
    }
    ...
    which indicates to me that tcludp is working fine.

    All above was done on a Fedora 17 virtual machine using Virtual Box.

     
  • Don Porter

    Don Porter - 2014-08-21

    Please demonstrate the problem with
    the release candidate of Tcl 8.6.2:

    ftp://ftp.tcl.tk/pub/tcl/tcl8_6/tcl862rc1-src.zip

     
  • Huub Eikens

    Huub Eikens - 2014-08-24
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,3 @@
    -
     When a Tcl_DriverInputProc() returns the value 0,
     the core I/O parts of Tcl take that to mean a signal
     of EOF on the channel.  udpInput() is returning 0
    
    • status: open --> closed-fixed
     
  • Huub Eikens

    Huub Eikens - 2014-08-24

    Solved in version 1.0.11

     

Log in to post a comment.