I'm having an issue and I can't figure out for the life of me what the problem is.
I've got an AJAX request which parses packets of data to a php script which processes the packet and writes the output to a log.
The whole thing runs perfectly ... unless I put a sleep(rand(2,20)); in the php script which makes it pause for awhile after processing each element in a packet. When I put the time delay in then sometimes in the middle of processing a packet the php script will seemingly stop and restart itself and process the whole packet again.
I've ruled out that the AJAX might be sending the request again while the php script is running by putting a flag in the AJAX so it can't send anything while the phpscript is running.
What could be causing this? I can't find anything about the problem.