SET TIMER CANCEL must be used with caution
search cancel

SET TIMER CANCEL must be used with caution

book

Article ID: 28857

calendar_today

Updated On:

Products

IDMS IDMS - Database

Issue/Introduction

TIMER TASKs are maintained in the IDMS CV as a linked list of control blocks called ICEs. Each ICE has pointers containing the address of the next and prior ICE in the list.

When any SET TIMER statement uses a TIMER ID, it is the address of the ICE which is stored in the field referenced by the TIMER ID clause.

When the following code executes:- 

SET TIMER START INTERVAL 60 SECONDS TASK CODE 'TASKA' TIMER ID WS-TIMER-ID.

a timer task is created and the address of the ICE returned in WS-TIMER-ID. Then with this code:-

SET TIMER CANCEL TIMER ID WS-TIMER-ID. 

that timer task will be removed.

The problem is that it is almost impossible to be sure that the address saved in WS-TIMER-ID is still the address of the same ICE.  

 

 

Environment

Release: All supported releases.

Cause

In practice, what happens most is that the SET TIMER START and SET TIMER CANCEL statements are in different programs, or different executions of the same program. If the ICE has expired in the mean time and another SET TIMER START issued by any other program in the CV, then that timer task could occupy the same address in storage. If that happens, the SET TIMER CANCEL will still work, but cancel the newly established timer task successfully, and complete with a 0000 ERROR-STATUS. There is no way to know that that wasn't the timer task that the program was intending to cancel.

Resolution

The only way to avoid this is if the SET TIMER START and the SET TIMER CANCEL are in the same execution of the same program and the logic of the program is such that it is impossible for the timer task to have expired.

If the intended behaviour cannot be achieved in such a way that the logic dictates that the correct timer task will still be at the same ICE address, then an alternate solution must be found.

If the reason that the program wants to cancel an existing timer task is just because it really wants to set a new one but also be sure that none already exists so that a duplicate won't be created, it is recommended to use callable DCMT to issue a DCMT D TIME TASKS and analyze the output. If one already exists then suppress the call to set a new one.