From 1611057852417c7d355d4289c2d394e9e7bc35cf Mon Sep 17 00:00:00 2001 From: Simon Zolin Date: Tue, 16 Apr 2019 18:36:10 +0300 Subject: [PATCH] * setRlimit(): move OS-specific code to separate files --- app.go | 12 ------------ os_unix.go | 21 +++++++++++++++++++++ os_windows.go | 5 +++++ 3 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 os_unix.go create mode 100644 os_windows.go diff --git a/app.go b/app.go index 0ba9a765..dacf1034 100644 --- a/app.go +++ b/app.go @@ -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") diff --git a/os_unix.go b/os_unix.go new file mode 100644 index 00000000..12a918c8 --- /dev/null +++ b/os_unix.go @@ -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) + } +} diff --git a/os_windows.go b/os_windows.go new file mode 100644 index 00000000..1155e04b --- /dev/null +++ b/os_windows.go @@ -0,0 +1,5 @@ +package main + +// Set user-specified limit of how many fd's we can use +func setRlimit(val uint) { +}