diff options
author | dgp <dgp@noemail.net> | 2014-10-17 15:20:34 (GMT) |
---|---|---|
committer | dgp <dgp@noemail.net> | 2014-10-17 15:20:34 (GMT) |
commit | e770c1ef59718fa714e17e91db88cbb3030a88c3 (patch) | |
tree | 51ac3aae97c75ade5379471958a041a26e43d5a8 /generic/tclIO.c | |
parent | 12ee4ec3cb79d45a4fa3ffd111c56b8d69b5ee87 (diff) | |
download | tcl-e770c1ef59718fa714e17e91db88cbb3030a88c3.zip tcl-e770c1ef59718fa714e17e91db88cbb3030a88c3.tar.gz tcl-e770c1ef59718fa714e17e91db88cbb3030a88c3.tar.bz2 |
[10dc6daa37] [gets] on a non-blocking channel must take care so that
1) At least one call to the channel driver input proc gets made.
Failure to do this locks up the channel - catastrophic FAIL.
2) After any driver call reports BLOCKED, don't call again.
This is less serious, but FAILs to respect the non-blocking setting.
Code corrections and tests included, to restore 8.5.15 compat.
FossilOrigin-Name: 87fc2707a08cdebd353814f1a982ef0a6f9feeda
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r-- | generic/tclIO.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index d1f22c1..e786946 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -4042,6 +4042,7 @@ Tcl_GetsObj( eof = NULL; inEofChar = statePtr->inEofChar; + ResetFlag(statePtr, CHANNEL_BLOCKED); while (1) { if (dst >= dstEnd) { if (FilterInputBytes(chanPtr, &gs) != 0) { @@ -4211,6 +4212,10 @@ Tcl_GetsObj( } goto gotEOL; } + if (GotFlag(statePtr, CHANNEL_BLOCKED|CHANNEL_NONBLOCKING) + == (CHANNEL_BLOCKED|CHANNEL_NONBLOCKING)) { + goto restore; + } dst = dstEnd; } @@ -4386,6 +4391,7 @@ TclGetsObjBinary( /* Only handle TCL_TRANSLATE_LF and TCL_TRANSLATE_CR */ eolChar = (statePtr->inputTranslation == TCL_TRANSLATE_LF) ? '\n' : '\r'; + ResetFlag(statePtr, CHANNEL_BLOCKED); while (1) { /* * Subtract the number of bytes that were removed from channel |