Patchwork D10776: revlog: close the index file handle after the data one

login
register
mail settings
Submitter phabricator
Date May 27, 2021, 7:06 a.m.
Message ID <differential-rev-PHID-DREV-2iixfdndpbods2uffcci-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49096/
State Superseded
Headers show

Comments

phabricator - May 27, 2021, 7:06 a.m.
marmoute created this revision.
Herald added a reviewer: indygreg.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This make sure the data file is flushed before the index. preventing the index
  to reference unflushed data.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10776

AFFECTED FILES
  mercurial/revlog.py

CHANGE DETAILS




To: marmoute, indygreg, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -2267,10 +2267,12 @@ 
                     self._write_docket(transaction)
             finally:
                 self._writinghandles = None
+                if dfh is not None:
+                    dfh.close()
+                # closing the index file last to avoid exposing referent to
+                # potential unflushed data content.
                 if ifh is not None:
                     ifh.close()
-                if dfh is not None:
-                    dfh.close()
 
     def _write_docket(self, transaction):
         """write the current docket on disk