Re: [tkined] side effect in Tcl_NotifyChannel introduced in tcl8.

Juergen Schoenwaelder (schoenw@ibr.cs.tu-bs.de)
Mon, 14 Sep 1998 19:04:22 +0200

>>>>> Dukhovni, Viktor writes:

Dukhovni> The 8.0.3 code is I believe correct. Tcl needs to protect
Dukhovni> channels around fileevent callbacks, and needs to complete
Dukhovni> of any channels that were closed in the callback once the
Dukhovni> channel is no longer needed by the code that dispatches the
Dukhovni> event.

It is correct that Tcl has to protect the channels around fileevent
callbacks. It is incorrect to close channels as a side effect of using
Tcl_RegisterChannel() and Tcl_UnregisterChannel(). My code does the
following:

channel = .... /* I get the channel from an accept callback */

Tcl_CreateChannelHandler(channel, TCL_READABLE, ...)

Tcl 8.0.3 closes the channel once the first event has been processed
on this channel. This looks like a bug. I could not find anything in
the description of Tcl_CreateChannelHandler or in the channels man
page which tells me that this is the intended behavior.

Dukhovni> I use Tnm 3.0.0 980501 and have not yet run into the problem
Dukhovni> you describe could be a little more specific as to were in
Dukhovni> the Tnm code the problem arises.

It happens at least on Solaris and Linux if you use the tkined
application. There might be other places in the scotty code where it
can cause problems.

Dukhovni> The best fix is to also call Tcl_RegisterChannel((Tcl_Interp
Dukhovni> *)NULL, channel) in your code, and call
Dukhovni> Tcl_UnregisterChannel() instead of Tcl_Close() to close the
Dukhovni> channel.

Sure, I probably have to do that. But I nevertheless consider the
current side-effect of Tcl_NotifyChannel a bug, not a feature. Lets
see what people at scriptics think about it.
Juergen

Juergen Schoenwaelder schoenw@ibr.cs.tu-bs.de http://www.cs.tu-bs.de/~schoenw
Technical University Braunschweig, Dept. Operating Systems & Computer Networks
Bueltenweg 74/75, 38106 Braunschweig, Germany. (Tel. +49 531 / 391 3289)

--
!! This message is brought to you via the `tkined & scotty' mailing list.
!! Please do not reply to this message to unsubscribe. To subscribe or
!! unsubscribe, send a mail message to <tkined-request@ibr.cs.tu-bs.de>.
!! See http://wwwsnmp.cs.utwente.nl/~schoenw/scotty/ for more information.