Hi Guys,
I have a caching system build within php that stores the results of a mysql query in xml. I lock the cache when building by creating a lock file with an exclusive write handle, and then remove it once the cache file is completed.
However, there are times when the script either times out or halts mid execution, leaving the lock file in place, making any further executions of the script think that the cache is always updating.
I have tried checking for the file being a number of minutes old and attempting to get an exclusive write access to the file to refresh the lock and begin execution, however it appears that the file is still open with the previous handle and I cannot open the new handle to ensure the current process is the only one with access and relock the file.
Is there a way to ensure that if the script is halted mid execution, any open file handles get closed and the files involved are available for future processes to access?
Thanks