Skip to content

write the parameter file in a safer way #54

@SebKuzminsky

Description

@SebKuzminsky

Currently (as of 2.7.4 and master commit 69e87f9) the interpreter saves the parameter file in an unsafe way:

  1. rename the current file with a backup extension
  2. create a new replacement parameter file by opening it for writing
  3. write out the parameters
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions