diff options
author | sebres <sebres@users.sourceforge.net> | 2017-07-03 13:28:04 (GMT) |
---|---|---|
committer | sebres <sebres@users.sourceforge.net> | 2017-07-03 13:28:04 (GMT) |
commit | a82f50e67930df0328c5d0d6ddecf54c2548eced (patch) | |
tree | d3ddc26f1318fd959a8f1c1cb1d5b70bc82bc238 | |
parent | 2ae514f620d54d6e84cd40faa493265aae2a91fe (diff) | |
download | tcl-a82f50e67930df0328c5d0d6ddecf54c2548eced.zip tcl-a82f50e67930df0328c5d0d6ddecf54c2548eced.tar.gz tcl-a82f50e67930df0328c5d0d6ddecf54c2548eced.tar.bz2 |
bug fix: prevent setting of negative block-time by too few initial wait-time, that may expire immediately (for example `vwait 0.0001 test`).
-rw-r--r-- | generic/tclEvent.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/generic/tclEvent.c b/generic/tclEvent.c index 186b8ae..05e3109 100644 --- a/generic/tclEvent.c +++ b/generic/tclEvent.c @@ -1446,16 +1446,18 @@ Tcl_VwaitObjCmd( blockTime.usec += 1000000; } /* be sure process at least one event */ - if (checktime) { - if ( blockTime.sec < 0 - || (blockTime.sec == 0 && blockTime.usec <= tolerance) - ) { - /* timeout occurs */ + if ( blockTime.sec < 0 + || (blockTime.sec == 0 && blockTime.usec <= tolerance) + ) { + /* timeout occurs */ + if (checktime) { done = -1; break; } + /* expired, be sure non-negative values here */ + blockTime.usec = blockTime.sec = 0; + checktime = 1; } - checktime = 1; Tcl_SetMaxBlockTime(&blockTime); } if ((foundEvent = Tcl_DoOneEvent(flags)) <= 0) { |