Tcl Source Code

View Ticket
Login
Ticket UUID: ac661a684d5abbdd0ef142176cfeb7a1a4f600b8
Title: Tcl_NotifyChannel man page: "no writable callback on pending flush" missing
Type: Bug Version: 8.6.1
Submitter: oehhar Created on: 2014-03-14 17:27:26
Subsystem: 25. Channel System Assigned To: dgp
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2020-11-17 10:12:22
Resolution: Fixed Closed By: oehhar
    Closed on: 2020-11-17 10:12:22
Description:

The man-page of Tcl_NotifyChannel http://www.tcl.tk/man/tcl8.6/TclLib/CrtChannel.htm writes:

Tcl_NotifyChannel is called by a channel driver to indicate to the generic layer that the events specified by mask have occurred on the channel. Channel drivers are responsible for invoking this function whenever the channel handlers need to be called for the channel.

It suggests that a registered writable proc is called after this notification. This is not the case, if a flush is pending and no error occured for the channel. In this case, a flush is tried and no proc is called.

IMHO this fact should be noted on the man-page.

The following code brings a channel in the state, where a Tcl_NotifyChannel will not fire the fileevent:

set h [socket -async unreachable a]
fileevent $h writable "puts Write;close $h"
fconfigure $h -blocking 0
puts $h ABC
flush $h
# Now a flush is pending on the socket
# When the cahnnel driver now calls Tcl_NotifyChannel, nothing happens the 

On a second call to Tcl_NotifyChannel, the fileevent will fire, as the first flush falied and it is in error state.

User Comments: oehhar added on 2020-11-17 10:12:22:

Added comment with checkin [b0f97d8082].


oehhar added on 2014-06-03 15:51:20:

Recent changes by DGP changed the behaviour like that:

If there is a flush pending, Tcl_NotifyChannel with writable flag set will invoke the flush. If the flush succeeds, the user function is not called.