summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2015-08-13 16:45:03 (GMT)
committerdgp <dgp@users.sourceforge.net>2015-08-13 16:45:03 (GMT)
commit13850d4952b34d30e3e2ae68c3cb2c10c0019737 (patch)
treedfd44064802e11ed2634e08abcd57c3cef837ae4
parent1db16b915a2fc6e315586502121d1ab7c9b39a59 (diff)
downloadtcl-13850d4952b34d30e3e2ae68c3cb2c10c0019737.zip
tcl-13850d4952b34d30e3e2ae68c3cb2c10c0019737.tar.gz
tcl-13850d4952b34d30e3e2ae68c3cb2c10c0019737.tar.bz2
A bit of code safety, and then a test demonstrating next issue.
-rw-r--r--generic/tclIORChan.c5
-rw-r--r--tests/io.test64
2 files changed, 67 insertions, 2 deletions
diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c
index 6592f9e..85a35b8 100644
--- a/generic/tclIORChan.c
+++ b/generic/tclIORChan.c
@@ -753,8 +753,11 @@ CallNotify(
int flags)
{
PostEvent *pevPtr = (PostEvent *)evPtr;
+ Channel *chanPtr = (Channel *)pevPtr->chan;
- Tcl_NotifyChannel(pevPtr->chan, pevPtr->events);
+ if (chanPtr->typePtr != NULL) {
+ Tcl_NotifyChannel(pevPtr->chan, pevPtr->events);
+ }
TclChannelRelease(pevPtr->chan);
return 1;
}
diff --git a/tests/io.test b/tests/io.test
index 46e3f05..840274d 100644
--- a/tests/io.test
+++ b/tests/io.test
@@ -7936,7 +7936,7 @@ test io-53.18 {[32ae34e63a] recursize CopyData} -setup {
# Different encoding to force use of DoReadChars()
chan configure $outChan -encoding iso8859-1
} -body {
- after 2000 {set ::done timeout}
+ after 100 {set ::done timeout}
chan copy $c $outChan -size 99 -command [list [namespace which more] $c $outChan]
vwait ::done
set ::done
@@ -7948,6 +7948,68 @@ test io-53.18 {[32ae34e63a] recursize CopyData} -setup {
unset ::done
} -result eof
+test io-53.19 {[e0a7b3e5f8] DoRead calls to UpdateInterest} -setup {
+ proc driver {cmd args} {
+ variable buffer
+ variable index
+ set chan [lindex $args 0]
+ switch -- $cmd {
+ initialize {
+ set index($chan) 0
+ set buffer($chan) [encoding convertto utf-8 \
+ [string repeat a 100]]
+ return {initialize finalize watch read}
+ }
+ finalize {
+ unset index($chan) buffer($chan)
+ return
+ }
+ watch {
+ if {"read" in [lindex $args 1]} {
+ chan postevent $chan read
+ }
+ return
+ }
+ read {
+ set n [lindex $args 1]
+ set new [expr {$index($chan) + $n}]
+ set result [string range $buffer($chan) $index($chan) $new-1]
+ set index($chan) $new
+ return $result
+ }
+ }
+ }
+ proc more {c outChan bytes args} {
+ if {[eof $c]} {
+ set ::done eof
+ catch {close $c}
+ return
+ }
+ if {[llength $args]} {
+ set ::done error
+ } else {
+ chan copy $c $outChan -size 30 -command [list [namespace which more] $c $outChan]
+ }
+ }
+ set c [chan create read [namespace which driver]]
+ chan configure $c -encoding utf-8 -buffersize 20
+ set out [makeFile {} out]
+ set outChan [open $out w]
+ # Different encoding to force use of DoReadChar()
+ chan configure $outChan -encoding iso8859-1
+} -body {
+ after 100 {set ::done timeout}
+ chan copy $c $outChan -size 30 -command [list [namespace which more] $c $outChan]
+ vwait ::done
+ set ::done
+} -cleanup {
+ catch {close $outChan}
+ removeFile out
+ rename driver {}
+ rename more {}
+ unset ::done
+} -result eof
+
test io-54.1 {Recursive channel events} {socket fileevent} {
# This test checks to see if file events are delivered during recursive
# event loops when there is buffered data on the channel.