]> arthur.barton.de Git - bup.git/commitdiff
git.py: flush idx_map before close so FILE* operations will see changes.
authorRob Browning <rlb@defaultvalue.org>
Sat, 8 Jun 2013 15:25:33 +0000 (10:25 -0500)
committerRob Browning <rlb@defaultvalue.org>
Sat, 8 Jun 2013 15:26:36 +0000 (10:26 -0500)
Flush idx_map (msync()) before closing it, since it doesn't look like
POSIX guarantees that a matching FILE* (i.e. idx_f) will see the
parallel changes if we don't.

From the original report:

  After `bup save`, `git fsck` would show messages like
  "Packfile index for %s SHA1 mismatch"
  This indicated a bad trailing checksum on the pack index file.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Reported-by: Alan Jenkins <alan.christopher.jenkins@gmail.com>
Reviewed-by: Alan Jenkins <alan.christopher.jenkins@gmail.com>
Tested-by: Alan Jenkins <alan.christopher.jenkins@gmail.com>
lib/bup/git.py

index 403b969baf9aa7451e55377a6455e473705fe990..00975a713d8849f9d110d0271b657c535cd3b3d0 100644 (file)
@@ -664,6 +664,10 @@ class PackWriter:
         idx_f.seek(0, os.SEEK_END)
         count = _helpers.write_idx(idx_f, idx_map, idx, self.count)
         assert(count == self.count)
+        # Sync, since it doesn't look like POSIX guarantees that a
+        # matching FILE* (i.e. idx_f) will see the parallel changes if
+        # we don't.
+        idx_map.flush()
         idx_map.close()
         idx_f.write(packbin)