Multiple users writing to the same file
have to admit that I am not really too sure where this one lives.
I have written an assett tracking utility that writes to a single manifest file on certain actions.
What I would like to do is have several users using this utility and whilst the chances of it are fairly slim it would be possible to have two processes trying to write to the same file at the same time. Other than the obvious potential problem that this (maybe?) presents, there is also the issue that the script in question is reading data out of the file and incrementing a number by one before re-inserting the entry back into the manifest file.
are there any inbuilt checks within the system to prevent this occuring or would I just need to do something "basic" like renaming the file before I write any information into it and have all other processes checking for the existance of the file and waiting if it is not present?
ie process renames manifest to manifestinuse whilst it manipulated the data. Any subsequent processes check for manifest/manifestinuse and performs the relevant action (either write to file or wait an amount of time and recheck).
|