Stop 2 identical queries from executing almost simultaneously?
Posted
by James Simpson
on Stack Overflow
See other posts from Stack Overflow
or by James Simpson
Published on 2010-03-13T22:14:32Z
Indexed on
2010/03/13
22:25 UTC
Read the original article
Hit count: 305
I have developed an AJAX based game where there is a bug caused (very remote, but in volume it happens at least once per hour) where for some reason two requests get sent to the processing page almost simultaneously (the last one I tracked, the requests were a difference of .0001 ms). There is a check right before the query is executed to make sure that it doesn't get executed twice, but since the difference is so small, the check hasn't finished before the next query gets executed. I'm stumped, how can I prevent this as it is causing serious problems in the game.
Just to be more clear, the query is starting a new round in the game, so when it executes twice, it starts 2 rounds at the same time which breaks the game, so I need to be able to stop the script from executing if the previous round isn't over, even if that previous round started .0001 ms ago.
© Stack Overflow or respective owner