Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2005-06-17
21:28 • Closed ticket [1221395fff]: Cannot break 'vwait' with Tcl_LimitSetTime</... artifact: b576d6abc6 user: dkf
2005-06-16
05:42 • Ticket [1221395fff]: 2 changes artifact: 6fcd183c7b user: dkf
2005-06-15
17:29 • New ticket [1221395fff]. artifact: 5c71eae06e user: nobody

Cannot break 'vwait' with Tcl_LimitSetTime

Closed / Fixed1221395fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 21 years ago
Descriptionplain2005-06-15 17:29:56
Tcl 8.5a3, Windows 2000

It is impossible to stop interpreter from outside ('master' 
C code) by using Tcl_LimitSetTime when script is 
executing vwait command. The following code was 
written in 'master':

limitTime.usec = 1;
limitTime.sec = 0;
Tcl_LimitSetGranularity( interp, TCL_LIMIT_TIME, 1 );
Tcl_LimitTypeSet( interp, TCL_LIMIT_TIME );
Tcl_LimitSetTime( interp, &limitTime );
Tcl_LimitCheck( interp );

and doesn't work (I suspect that Tcl_LimitTypeSet() 
should be enough indeed)

I've modified TCL sources a bit and it started to work but I 
don't know TCL sources well, so this could be a bad way.

In tclInterp.c, Tcl_LimitCheck()   (Send alert each time 
limit check is hit)
...
>      Tcl_Preserve(interp);
>      RunLimitHandlers(iPtr->limit.timeHandlers, interp);

+      Tcl_ThreadAlert( NULL );

>      if (iPtr->limit.time.sec > now.sec ||
...

In tclNotify.c, Tcl_ThreadAlert()   (support for 'broadcast' 
events, without exact threadId known)
...
>    for (tsdPtr = firstNotifierPtr; tsdPtr; tsdPtr = tsdPtr-
>nextPtr) {
+if ((threadId == NULL) || (tsdPtr->threadId == threadId)) 
{
>    if (tclStubs.tcl_AlertNotifier) {
...

And the last thing is that even after all that done 
Tcl_WaitForEvent returns 0 and Tcl_DoOneEvent() do not 
warns vwait about changes happened, so I had to make 
Tcl_WaitForEvent always return 1.

I believe there can be a graceful solution of this problem 
(if there IS problem).

nyrl at mail dot ru
dkf Ticket [1221395fff]: 2 changes [History diff]2005-06-16 05:42:09
dkfplain2005-06-17 21:28:27
Logged In: YES 
user_id=79902

Turns out to have been a problem with [after]'s handling of
time limit mathematics. Fixed in HEAD.
Log in (anonymous is fine) to add a comment.