My flock() code works fine when run live to the user over http
However when the same code is spawned via exec() it all works except the flock()
flock($handle, LOCK_EX + LOCK_Nš always returns an error (never gets the lock)
(Yes I have checked that $handle is valid
Yes I do have backoff and retries
Permissions on the file are set to 777)
Now, I suspect the answer is not to use flock() at all, rather than try to resolve this problem.
So what else do I do? I am trying to control access to an external resource that has a one-poll-per-second limitation.
Should I be using MySQL? Does this have the necessary atomicity? If so, which particular combination of calls?
I have tried to search for an idiot's guide to process synchronization using MySQL but with no luck.
Any help greatly appreciated.