Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Thread safe Crudini #6
This is a good point. We write with first a truncation, then a write. Really we should open a tmp file and rename it in place which is an atomic operation. Now that does require write access to a directory on the same file system rather than just write access to the ini file in question. Also we have to be careful to ensure the attributes of the new and old file are the same which is tricky given extended attributes etc.
The above will ensure that the ini file is consistent for a particular run, though there are stil races possible where the complete changes for a run are overwritten by those of another overlapping run. You'd need higher level locking in place to avoid that.
So that would be the "higher level locking" I mentioned to cater for all cases
This comment has been minimized.
This comment has been minimized.Show comment Hide comment
Some more notes.
To ensure data consistency, i.e. ini file readers only
To ensure that concurrent edits by crudini don't silently discard changes