-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Currently (as of 2.7.4 and master commit 69e87f9) the interpreter saves the parameter file in an unsafe way:
- rename the current file with a backup extension
- create a new replacement parameter file by opening it for writing
- write out the parameters
- close the file to save it
This is done in src/emc/rs274ngc/rs274ngc_pre.cc's Interp::save_parameters().
This has the danger that something can go wrong after 1 but before 4 (such as the operator removing power to the machine), resulting in corruption.
A safer alternative would be to copy the existing parameter file to a backup, write the new parameter file to a temporary file, then atomically renaming the temporary file to the real parameter file, replacing it.
Another alternative would be to look into a lightweight key/value store, perhaps in a separate process. This would have the benefit of not blocking Task if disk access is slow, which is currently a major source of userspace/non-realtime latency in linuxcnc.
This fix should be made in master, not in a stable/release branch.