Suffix depslog path records with their expected index.
authorNico Weber <thakis@chromium.org>
Mon, 26 Aug 2013 22:19:21 +0000 (15:19 -0700)
committerNico Weber <thakis@chromium.org>
Mon, 26 Aug 2013 22:28:34 +0000 (15:28 -0700)
commit65ad26801e19b35a386e82491ed32085adbf1a85
tree26689f2f8f76c005d4a45f1172db52e41b3f2a4a
parent8c782f12e049ea44c02332f574867e2290204c7f
Suffix depslog path records with their expected index.

ninja assumes that numbering path entries in the deps log in order produces
valid dense integer ids.  If two ninja processes write to the same deps log
concurrently, this is not true.  Store the expected indices of path records
in the log and treat the rest of a deps log as invalid if the dense id of a
path record doesn't match the expected id stored in the log.  Addresses the
rest of issue #595.

This requires bumping the deps log file format version.  Do not migrate the
old version to the new, as the old format did not have this protection, and
might hence contain invalid data.  (Unlikely, but possible.)

Also store the record id as one's complement, to make them look less like
regular deps record values.  Since each record is written atomically this
isn't really necessary, but it makes the format somewhat more robust (and
easier to read in a hex editor).
src/deps_log.cc
src/deps_log.h