Compare commits

...
2 changed files with 31 additions and 4 deletions
+25 -4
View File
@@ -2118,7 +2118,7 @@ Tcl_GetChannelHandle(
chanPtr = ((Channel *) chan)->state->bottomChanPtr;
if (!chanPtr->typePtr->getHandleProc) {
Tcl_SetChannelError(chan, Tcl_ObjPrintf(
"channel \"%s\" does not support OS handles",
"{channel \"%s\" does not support OS handles}",
Tcl_GetChannelName(chan)));
return TCL_ERROR;
}
@@ -2453,13 +2453,35 @@ FlushChannel(
*/
if ((errorCode == EWOULDBLOCK) || (errorCode == EAGAIN)) {
/*
* This used to check for CHANNEL_NONBLOCKING, and panic if
/* PREVIOUS RATIONALE -- UNDER EVALUATION
*
* This used to check for CHANNEL_NONBLOCKING, and panic if
* the channel was blocking. However, it appears that setting
* stdin to -blocking 0 has some effect on the stdout when
* it's a tty channel (dup'ed underneath)
*/
/* NEW RATIONALE -- UNDER EVALUATION
*
* We explicitly disallow EAGAIN/EWOULDBLOCK for blocking
* channels, but throw an error instead of panicking, since
* this may be a simple scripting error in a refelected
* channel.
*/
if (!GotFlag(statePtr, CHANNEL_NONBLOCKING)) {
//Tcl_Panic("EAGAIN Illegally thrown by blocking channel");
Tcl_SetChannelError((Tcl_Channel) chanPtr,
Tcl_ObjPrintf("{EAGAIN Illegally thrown by blocking channel \"%s\"}",
Tcl_GetChannelName((Tcl_Channel)chanPtr)));
errorCode=EINVAL;
DiscardOutputQueued(statePtr);
goto done;
}
if (!GotFlag(statePtr, BG_FLUSH_SCHEDULED)) {
SetFlag(statePtr, BG_FLUSH_SCHEDULED);
UpdateInterest(chanPtr);
@@ -2524,7 +2546,6 @@ FlushChannel(
* When we get an error we throw away all the output currently
* queued.
*/
DiscardOutputQueued(statePtr);
continue;
} else {
+6
View File
@@ -1214,6 +1214,7 @@ test iocmd-24.15 {chan write, EAGAIN means that writing is not allowed at this t
error EAGAIN
}
set c [chan create {r w} foo]
fconfigure $c -blocking 0
} -body {
note [puts -nonewline $c ABC ; flush $c]
set res
@@ -2566,6 +2567,7 @@ test iocmd.tf-24.15 {chan write, EAGAIN means that writing is not allowed at thi
error EAGAIN
}
set c [chan create {r w} foo]
fconfigure $c -blocking 0
} -body {
notes [inthread $c {
note [puts -nonewline $c ABC ; flush $c]
@@ -2575,6 +2577,7 @@ test iocmd.tf-24.15 {chan write, EAGAIN means that writing is not allowed at thi
set res
} -cleanup {
proc foo {args} {onfinal; set ::done-24.15 1; return 3}
after 1000 {set ::done-24.15 2}
vwait done-24.15
rename foo {}
unset res
@@ -2592,6 +2595,7 @@ test iocmd.tf-24.16 {chan write, note the background flush setup by close due to
error EAGAIN
}
set c [chan create {r w} foo]
fconfigure $c -blocking 0
} -body {
notes [inthread $c {
note [puts -nonewline $c ABC ; flush $c]
@@ -2603,10 +2607,12 @@ test iocmd.tf-24.16 {chan write, note the background flush setup by close due to
proc foo {args} { onfinal; note BG ; track ; set ::endbody-24.16 1}
# Flush (sic!) the event-queue to capture the write from a
# BG-flush.
after 1000 {set ::endbody-24.16 2}
vwait endbody-24.16
set res
} -cleanup {
proc foo {args} {onfinal; set ::done-24.16 1; return 3}
after 1000 {set ::done-24.16 2}
vwait done-24.16
rename foo {}
unset res