File tree 3 files changed +14
-1
lines changed
3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 53
53
54
54
#include " llvm/CAS/MappedFileRegionBumpPtr.h"
55
55
#include " OnDiskCommon.h"
56
- #include " llvm/ADT/StringMap.h"
57
56
#include " llvm/CAS/OnDiskCASLogger.h"
58
57
59
58
using namespace llvm ;
@@ -196,6 +195,8 @@ void MappedFileRegionBumpPtr::destroyImpl() {
196
195
size_t Size = size ();
197
196
size_t Capacity = capacity ();
198
197
assert (Size < Capacity);
198
+ // sync to file system to make sure all contents are up-to-date.
199
+ (void )Region.sync ();
199
200
(void )sys::fs::resize_file (*FD, size ());
200
201
(void )unlockFileThreadSafe (*SharedLockFD);
201
202
Original file line number Diff line number Diff line change @@ -876,6 +876,12 @@ void mapped_file_region::unmapImpl() {
876
876
::munmap (Mapping, Size );
877
877
}
878
878
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
+
879
885
void mapped_file_region::dontNeedImpl () {
880
886
assert (Mode == mapped_file_region::readonly);
881
887
if (!Mapping)
Original file line number Diff line number Diff line change @@ -1011,6 +1011,12 @@ void mapped_file_region::unmapImpl() {
1011
1011
1012
1012
void mapped_file_region::dontNeedImpl () {}
1013
1013
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
+
1014
1020
int mapped_file_region::alignment () {
1015
1021
SYSTEM_INFO SysInfo;
1016
1022
::GetSystemInfo (&SysInfo);
You can’t perform that action at this time.
0 commit comments