Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 7ac3efff authored by Sharvil Nanavati's avatar Sharvil Nanavati Committed by Andre Eisenbach
Browse files

Atomically update config files.

There's a race condition on shutdown between Java and native code.
A stack shutdown is issued from Java and in the meantime the
calling thread calls System.exit(0). If that line is reached before
the native code has had a chance to shut down cleanly, the system
could be stuck in a bad state.

This change uses rename(2) to replace an existing config file
atomically instead of truncating, writing, and then flushing. In
case of a crash or the race condition above, the config file will
still be valid.

There's an implementation gotcha. The config saving code uses ".new"
as a suffix on the original filename to write to a temporary file.
If a file by that name already exists, it will be overwritten.
parent e0a3e23f
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment