Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 2714548ae2ee28720731ed5e124357fc41046d1471636948d3dd0a326c7ee971
Ticket: 65c9cd1534b6e722bbc221ba917d0865a66a50e6
TIP 562 changes broke the trunk
User & Date: dgp on 2020-03-04 19:54:20
Changes

  1. icomment:
    
    What a mess.
    
    Part of Tcl_Close in Tcl 8.6 sources looks like this:
    
        /*
         * If this channel supports it, close the read side, since we don't need
         * it anymore and this will help avoid deadlocks on some channel types.
         */
    
        if (chanPtr->typePtr->closeProc == TCL_CLOSE2PROC) {
            result = chanPtr->typePtr->close2Proc(chanPtr->instanceData, interp,
                    TCL_CLOSE_READ);
            if (result == EINVAL) {
                result = 0;
            }
        }
    
    Based on the comment, the value TCL_CLOSE2PROC is being used to signal the existence of a half-close supporting close2Proc in the Tcl_ChannelType. This
    is true, but this is not the only way such a thing can be present. Surely it
    is more reliable and correct to just test the close2Proc entry itself. Arguably
    this has always been a bug.
    
    But since the code has never been written that way, it has always skipped
    over the half-close attempt for any channel that provides a real closeProc,
    which the unix "tcp" channel does. At a minimum, our own channels are bug
    dependent.
    
    With recent changes that ignored the possibility of independent closeProc
    and close2Proc entries in the channel type, we now have a half-close getting
    called on "tcp" channels for the first time as part of a typical [close].
    
    When the socket connection isn't good, the half-close can raise ENOTCONN.
    While Tcl_Close filters out EINVAL, it lets ENOTCONN through, so for the
    first time with these changes we have [close] raising errors. This is a
    script level incompat. Unwelcome. Somewhere we need to restore the behavior
    that detection of a bad connection during a [close] doesn't cause [close]
    to throw an error (especially not one with NO error message or code!)
    
  2. login: "dgp"
  3. mimetype: "text/plain"