Increase the maximum file handler from 1K to 1M (#16)

The default file handler limitation on Linux for each process is 1K, which could be too few. Increase this number to 1M for hdfs-mount process only.
This option requires sudo privilege, or no change happens with an error msg.
This commit is contained in:
Junjie Qian 2017-03-17 09:19:19 -07:00 коммит произвёл GitHub
Родитель e4218b854f
Коммит b85f319dc3
1 изменённых файлов: 9 добавлений и 0 удалений

Просмотреть файл

@ -81,6 +81,15 @@ func main() {
}
log.Print("Mounted successfully")
// Increase the maximum number of file descriptor from 1K to 1M in Linux
rLimit := syscall.Rlimit {
Cur: 1024*1024,
Max: 1024*1024}
err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
Error.Printf("Failed to update the maximum number of file descriptors from 1K to 1M, %v", err)
}
defer func() {
fileSystem.Unmount()
log.Print("Closing...")