Skip to content

Commit 58dc05f

Browse files
committed
fixed #492
1 parent ad6d3ac commit 58dc05f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

mars/comm/mmap_util.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ bool OpenMmapFile(const char* _filepath, unsigned int _size, boost::iostreams::m
4242
return false;
4343
}
4444

45-
boost::iostreams::mapped_file_params param;
46-
param.path = _filepath;
45+
boost::iostreams::basic_mapped_file_params<boost::filesystem::path> param;
46+
param.path = boost::filesystem::path(_filepath);
4747
param.flags = boost::iostreams::mapped_file_base::readwrite;
4848

4949
bool file_exist = boost::filesystem::exists(_filepath);
@@ -54,15 +54,15 @@ bool OpenMmapFile(const char* _filepath, unsigned int _size, boost::iostreams::m
5454
_mmmap_file.open(param);
5555

5656
bool is_open = IsMmapFileOpenSucc(_mmmap_file);
57-
57+
#ifndef _WIN32
5858
if (!file_exist && is_open) {
5959

6060
//Extending a file with ftruncate, thus creating a big hole, and then filling the hole by mod-ifying a shared mmap() can lead to SIGBUS when no space left
6161
//the boost library uses ftruncate, so we pre-allocate the file's backing store by writing zero.
6262
FILE* file = fopen(_filepath, "rb+");
6363
if (NULL == file) {
6464
_mmmap_file.close();
65-
remove(_filepath);
65+
boost::filesystem::remove(_filepath);
6666
return false;
6767
}
6868

@@ -72,14 +72,14 @@ bool OpenMmapFile(const char* _filepath, unsigned int _size, boost::iostreams::m
7272
if (_size != fwrite(zero_data, sizeof(char), _size, file)) {
7373
_mmmap_file.close();
7474
fclose(file);
75-
remove(_filepath);
75+
boost::filesystem::remove(_filepath);
7676
delete[] zero_data;
7777
return false;
7878
}
7979
fclose(file);
8080
delete[] zero_data;
8181
}
82-
82+
#endif
8383
return is_open;
8484
}
8585

0 commit comments

Comments
 (0)