Skip to content

Commit 0fc258e

Browse files
committed
Revert "Geofiles: Implement mmap in filesystem to reduce ram usage (#5480)"
This reverts commit 5d94a62.
1 parent 1fc5b7a commit 0fc258e

2 files changed

Lines changed: 0 additions & 80 deletions

File tree

common/platform/filesystem/file.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
//go:build !windows && !wasm
2-
31
package filesystem
42

53
import (
64
"io"
75
"os"
86
"path/filepath"
9-
"syscall"
107

118
"github.com/xtls/xray-core/common/buf"
129
"github.com/xtls/xray-core/common/platform"
@@ -19,29 +16,6 @@ var NewFileReader FileReaderFunc = func(path string) (io.ReadCloser, error) {
1916
}
2017

2118
func ReadFile(path string) ([]byte, error) {
22-
file, err := os.Open(path)
23-
if err != nil {
24-
return nil, err
25-
}
26-
defer file.Close()
27-
28-
stat, err := file.Stat()
29-
if err != nil {
30-
return nil, err
31-
}
32-
33-
size := stat.Size()
34-
if size == 0 {
35-
return []byte{}, nil
36-
}
37-
38-
// use mmap to save RAM
39-
bs, err := syscall.Mmap(int(file.Fd()), 0, int(size), syscall.PROT_READ, syscall.MAP_SHARED)
40-
if err == nil {
41-
return bs, nil
42-
}
43-
44-
// fallback
4519
reader, err := NewFileReader(path)
4620
if err != nil {
4721
return nil, err

common/platform/filesystem/file_other.go

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)