* setRlimit(): move OS-specific code to separate files

This commit is contained in:
Simon Zolin 2019-04-16 18:36:10 +03:00
parent 00ba63341b
commit 1611057852
3 changed files with 26 additions and 12 deletions

12
app.go
View File

@ -311,18 +311,6 @@ func enableTLS13() {
}
}
// Set user-specified limit of how many fd's we can use
// https://github.com/AdguardTeam/AdGuardHome/issues/659
func setRlimit(val uint) {
var rlim syscall.Rlimit
rlim.Max = uint64(val)
rlim.Cur = uint64(val)
err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim)
if err != nil {
log.Error("Setrlimit() failed: %v", err)
}
}
func cleanup() {
log.Info("Stopping AdGuard Home")

21
os_unix.go Normal file
View File

@ -0,0 +1,21 @@
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
package main
import (
"syscall"
"github.com/AdguardTeam/golibs/log"
)
// Set user-specified limit of how many fd's we can use
// https://github.com/AdguardTeam/AdGuardHome/issues/659
func setRlimit(val uint) {
var rlim syscall.Rlimit
rlim.Max = uint64(val)
rlim.Cur = uint64(val)
err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim)
if err != nil {
log.Error("Setrlimit() failed: %v", err)
}
}

5
os_windows.go Normal file
View File

@ -0,0 +1,5 @@
package main
// Set user-specified limit of how many fd's we can use
func setRlimit(val uint) {
}