Go Back

i8 evaluation not working

I have encountered a very strange i8 evaluation issue. The customer has a web portal that is using xfServer+ to run Synergy elb code, we have introduced some logic to restart a function in a detached process if a time limit is exceeded. The evaluation of this time limit doesn't work unless I happen to write the values being evaluated out to a log file.
I added the log file write to evaluate why it wasn't working and suddenly it did work, when I removed the logic it once again failed. If kept the open and close but left out the write it still failed.
I have a sample of the code below:
 

begin
	data curr_time	,i8			;setup variable to evaluate time
	curr_time = %DATETIME_TO_I8(%datetime)	;get the current time
	
	;-------------------------------------------------------------
	; logging logic to evaluate why the evaluation was not working
	xcall getchn(ps.chn_tmp_log_file)			;get a channel for the log file
	open(ps.chn_tmp_log_file,o,ps.filename_base+".chk")	;open the log file
	xcall s_bld(ps.cmdlin,,'CUR TIME:%d  STOP TIME:%d',curr_time,ps.stop_time)	;generate a text line to output
	writes (ps.chn_tmp_log_file,ps.cmdlin)			;write the text to the log file
	xcall close2zero(ps.chn_tmp_log_file)			;close the channel
	;-------------------------------------------------------------
	; removing the code above between the "---" the (curr_time .gt. ps.stop_time) doesn't evaluate properly and never becomes true
    ; re-introducing the code above, recompiling and re-executing the code via xfServer+ the function does evaluate the 
    ; (curr_time .gt. ps.stop_time) correctly

	if (curr_time .gt. ps.stop_time .or. ps.rec_counter .gt. ps.max_rec_count)
	then	; Test if the detached parameters have been met and start a detached process if required
	begin
		xcall run_detached_ps(ps)	;-AM Start a detached process
		p_errmsg = ps.errmsg		;-AM Set the return message for LEWIS page (xfServer+)
		rvalue = 4			;-AM Set the return status for LEWIS page (xfServer+)
		goto fin_reads			;-AM Exit the function
	end
	else
	begin
		p_ds_prices.Add((@ds_prices)s_ds_prices)
		incr ps.rec_counter	; AM- Increment record counter for detached processing test
	end
end

 

2 Answers
0   | Posted by Andrew Meyer to xfServerPlus on 1/10/2022 7:20 PM
Bill Hawkins
Hi Andrew,
Just some basic troubleshooting questions
Are you using 32-bit or 64-bit Synergy?   Does it behave the same in both bit sizes? 
Have you tried moving the local data declaration of curr_time into the routine data division?   if so, have you tried using ".align QUAD"? 
Adding the code for logging has changed the size of the procedural section which may cause the compiler to emit the object code differently, and that may be contributing to the issue.
Regards

1/13/2022 10:56 PM   0  
Andrew Meyer
Hi Bill,

That is an interesting idea to use the ".align QUAD"
The code is being compiled as 32-bit for Linux platform. The "data curr_time i8" was added to see if testing a variable against a variable would make a difference and also so I could output the same value being evaluated against.
Originally the if statement read as:
if (%DATETIME_TO_I8(%DATETIME) .gt. ps.stop_time .or. ps.rec_counter .gt. ps.max_rec_count)

That version didn't work either and the "writes" statement in the original example above did the same in-line conversion of the current time.
Naturally when the writes and the evaluation were each doing their own inline conversion of the current time the value would change slightly between the execution of the two lines. I knew this for sure because the last value in the log still had the current time lower than the max_run_time. 

Before introducing the "DATA CURR_TIME ,I8" code I had gone to the step of only commenting out just the writes line specifically in which case the evaluation would fail to recognize the current_time had exceeded the stop_time.

For further clarification, the ps.stop_time is set in another piece of code (actually in a separate ELB library) and the "ps" variable in both pieces of code is derived as a datatype of "DETACHED_PS" from a Repository structure by the same name:
.include "DETACHED_PS" REPOSITORY, STRUCTURE = "DETACHED_PS", end  ; Include Data Structure for Detached Processing

.subroutine setup_stop_time_ps
    ps    ,Detached_PS ; Detached Processing Data Structure
    sel   ,String      ; Selection data from web page

...

.proc
ps.psdt = %datetime

...

reads (ps.chn_tmp_log_file,ps.asc_max_run_time) ; Read in max_run_time value (in minutes)
ps.max_run_time = ps.asc_max_run_time           ; Move value to I8 variable

...

ps.max_run_time = ps.max_run_time * 60 * 1000000          ; Convert minutes into microseconds
ps.stop_time = %DATETIME_TO_I8(ps.psdt) + ps.max_run_time ; Add runtime to current time

...

.end

 

1/13/2022 11:43 PM   0  
Please log in to comment or answer this question.