Does any one have an idea about how to solve race condition in php
whoisgregg
2:41 pm on Dec 3, 2010 (gmt 0)
Well, in general terms if you have three processes (A, B, C) and C can only complete successfully after A and B have completed, then your code for process C needs to test to make sure that A and B have successfully completed.
Race conditions are pretty unusual in PHP though. How did you end up with one?
JuicyScript
4:31 pm on Dec 3, 2010 (gmt 0)
Am writing a php script which will count $count+1 anytime a user submits a value to the database till it get to 10. What am trying to avoid is when two people click submit at the same time,the script is going to count it as one. i want a way to keep the users waiting in a queue.So it executes one after the other.
eelixduppy
5:00 pm on Dec 3, 2010 (gmt 0)
So do just that. Have a process that enqueues the user's actions, and then one that dequeues them. Since a queue is serial, you shouldn't have two things happen at once.
Also, if you are worried about the database, the database should have mechanisms to ensure serializability.