OSCommerce Product Manager

OSCommerce Product Manager for Windows
Tasklist

FS#322 - Elapsed time checking may give wrong result.

Attached to Project: OSCommerce Product Manager
Opened by Mario A. Valdez-Ramirez (mvaldez) - Tuesday, 04 April 2006, 20:57 GMT-6
Last edited by Mario A. Valdez-Ramirez (mvaldez) - Saturday, 21 July 2007, 04:52 GMT-6
Task Type Bug Report
Category Backend / Core
Status Closed
Assigned To Mario A. Valdez-Ramirez (mvaldez)
Operating System All
Severity Low
Priority Normal
Reported Version any
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

At several places, specialy when waiting for a retry, the application check the current time (with milisec resolution) and it act accordingly. The usual checking is done with a GetTickCount functions.

We are aware of a possible problem if the computer (client-side, not server) is left running more than 49.7 days. The GetTickCount will be restarted.

We usually do this:

LapseTime := GetTickCount;
REPEAT
Application.ProcessMessages;
UNTIL ((GetTickCount - LapseTime) > opmG_HTTPConnWait);

The problem will happen if we start the loop and then the GetTickCount value is wrapped (restarted), the loop would take 49.7 days to complete (unless again it wraps before the cheking, which would extend the wait for 49.7 days).

Even though this would be a very rare occurrence, it should be fixed.
This task depends upon

Closed by  Mario A. Valdez-Ramirez (mvaldez)
Saturday, 21 July 2007, 04:52 GMT-6
Reason for closing:  
Comment by Mario A. Valdez-Ramirez (mvaldez) - Tuesday, 04 April 2006, 20:59 GMT-6

He he he. Microsoft recommends using GetTickCount64. The only detail it is that it is only available in Windows Vista. Funny guys.
Comment by Mario A. Valdez-Ramirez (mvaldez) - Saturday, 21 July 2007, 04:47 GMT-6
We should do:

LapseTime := GetTickCount;
REPEAT
Application.ProcessMessages;
UNTIL (((GetTickCount - LapseTime) > opmG_HTTPConnWait) OR (GetTickCount < LapseTime));

In this way, the second condition in the UNTIL will check if GetTickCount is lower than LapseTime (the starting time). GetTickCount will be always higher than LapseTime, unless it overflows and wrap arount to zero again. If that happes, the waiting time will be lower than expected, but that is far more better than freezing in a 49-days loop.
Comment by Mario A. Valdez-Ramirez (mvaldez) - Saturday, 21 July 2007, 04:52 GMT-6
Closing as fixed.

Loading...