Overview
| Artifact ID: | 18721a69ad5995b1368fc576d2798bf8e845e364 |
|---|---|
| Ticket: | 96c3f3b47d13052efb84fefb9328a195f407d859
No processing of after events |
| User & Date: | chw on 2017-02-16 00:41:37 |
Changes
- icomment:
Maybe the attached patch against tclTimer.c in core-8-6-branch fixes this. It clamps the maximum delay to 0x7fffffff milliseconds for Tcl_CreateTimerHandler() and to about LONG_MAX seconds for the after command. Test case on a 32 bit machine: after 0x600 {puts hoo} after [expr {0x80000000 * 1000}] {puts boo} after 0x800 {puts woah} --- tclTimer.c.orig 2016-09-02 07:02:59.968037508 +0200 +++ tclTimer.c 2017-02-16 01:25:06.847730219 +0100 @@ -121,7 +121,8 @@ */ #define TCL_TIME_BEFORE(t1, t2) \ - (((t1).sec<(t2).sec) || ((t1).sec==(t2).sec && (t1).usec<(t2).usec)) + ((((t1).sec - (t2).sec) < 0) || \ + ((t1).sec == (t2).sec && ((t1).usec - (t2).usec) < 0)) #define TCL_TIME_DIFF_MS(t1, t2) \ (1000*((Tcl_WideInt)(t1).sec - (Tcl_WideInt)(t2).sec) + \ @@ -259,6 +260,9 @@ * Compute when the event should fire. */ + if (milliseconds < 0) { + milliseconds = 0; + } Tcl_GetTime(&time); time.sec += milliseconds/1000; time.usec += (milliseconds%1000)*1000; @@ -873,11 +877,16 @@ afterPtr->id = tsdPtr->afterId; tsdPtr->afterId += 1; Tcl_GetTime(&wakeup); - wakeup.sec += (long)(ms / 1000); - wakeup.usec += ((long)(ms % 1000)) * 1000; - if (wakeup.usec > 1000000) { - wakeup.sec++; - wakeup.usec -= 1000000; + if (((wakeup.sec + (long)(ms / 1000)) - (wakeup.sec)) < 0) { + wakeup.sec += LONG_MAX - 1; + /* Don't consider fractional part. */ + } else { + wakeup.sec += (long)(ms / 1000); + wakeup.usec += ((long)(ms % 1000)) * 1000; + if (wakeup.usec > 1000000) { + wakeup.sec++; + wakeup.usec -= 1000000; + } } afterPtr->token = TclCreateAbsoluteTimerHandler(&wakeup, AfterProc, afterPtr); - login: "chw"
- mimetype: "text/plain"