File tree Expand file tree Collapse file tree 3 files changed +14
-1
lines changed Expand file tree Collapse file tree 3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 5353
5454#include " llvm/CAS/MappedFileRegionBumpPtr.h"
5555#include " OnDiskCommon.h"
56- #include " llvm/ADT/StringMap.h"
5756#include " llvm/CAS/OnDiskCASLogger.h"
5857
5958using namespace llvm ;
@@ -196,6 +195,8 @@ void MappedFileRegionBumpPtr::destroyImpl() {
196195 size_t Size = size ();
197196 size_t Capacity = capacity ();
198197 assert (Size < Capacity);
198+ // sync to file system to make sure all contents are up-to-date.
199+ (void )Region.sync ();
199200 (void )sys::fs::resize_file (*FD, size ());
200201 (void )unlockFileThreadSafe (*SharedLockFD);
201202
Original file line number Diff line number Diff line change @@ -876,6 +876,12 @@ void mapped_file_region::unmapImpl() {
876876 ::munmap (Mapping, Size);
877877}
878878
879+ std::error_code mapped_file_region::sync () const {
880+ if (int Res = ::msync (Mapping, Size, MS_SYNC))
881+ return std::error_code (Res, std::generic_category ());
882+ return std::error_code ();
883+ }
884+
879885void mapped_file_region::dontNeedImpl () {
880886 assert (Mode == mapped_file_region::readonly);
881887 if (!Mapping)
Original file line number Diff line number Diff line change @@ -1011,6 +1011,12 @@ void mapped_file_region::unmapImpl() {
10111011
10121012void mapped_file_region::dontNeedImpl () {}
10131013
1014+ std::error_code mapped_file_region::sync () const {
1015+ if (::FlushViewOfFile (Mapping, 0 ))
1016+ return std::error_code ();
1017+ return mapWindowsError (::GetLastError ());
1018+ }
1019+
10141020int mapped_file_region::alignment () {
10151021 SYSTEM_INFO SysInfo;
10161022 ::GetSystemInfo (&SysInfo);
You can’t perform that action at this time.
0 commit comments