Race conditions
Posted: Fri Apr 11, 2008 5:40 am
Hello, i have the following problem:
In a web-game there is a sort of arena in which the players can kill themselves, but everything happens in real time.
Now, I have a problem when two people click the Attack link at the same time.
Before trying to kill the other char, the software checks if the other one is alive, but if the players click the links at the same time (they attack each other simultaneously), the two selects on the db see they are both alive, and this results in a double kill.
I think i have to set up a kind of lock mechanism, anyone of you has implemented something like this or can point me to some documentation?
Thanks
In a web-game there is a sort of arena in which the players can kill themselves, but everything happens in real time.
Now, I have a problem when two people click the Attack link at the same time.
Before trying to kill the other char, the software checks if the other one is alive, but if the players click the links at the same time (they attack each other simultaneously), the two selects on the db see they are both alive, and this results in a double kill.
I think i have to set up a kind of lock mechanism, anyone of you has implemented something like this or can point me to some documentation?
Thanks