mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-09 14:50:56 +00:00
parent
b3fd9a8d53
commit
eca156fd7f
@ -8,7 +8,14 @@
|
|||||||
|
|
||||||
package osutil
|
package osutil
|
||||||
|
|
||||||
import "syscall"
|
import (
|
||||||
|
"runtime"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
darwinOpenMax = 10240
|
||||||
|
)
|
||||||
|
|
||||||
// MaximizeOpenFileLimit tries to set the resource limit RLIMIT_NOFILE (number
|
// MaximizeOpenFileLimit tries to set the resource limit RLIMIT_NOFILE (number
|
||||||
// of open file descriptors) to the max (hard limit), if the current (soft
|
// of open file descriptors) to the max (hard limit), if the current (soft
|
||||||
@ -26,6 +33,12 @@ func MaximizeOpenFileLimit() (int, error) {
|
|||||||
return int(lim.Cur), nil
|
return int(lim.Cur), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// macOS doesn't like a soft limit greater then OPEN_MAX
|
||||||
|
// See also: man setrlimit
|
||||||
|
if runtime.GOOS == "darwin" && lim.Max > darwinOpenMax {
|
||||||
|
lim.Cur = darwinOpenMax
|
||||||
|
}
|
||||||
|
|
||||||
// Try to increase the limit to the max.
|
// Try to increase the limit to the max.
|
||||||
oldLimit := lim.Cur
|
oldLimit := lim.Cur
|
||||||
lim.Cur = lim.Max
|
lim.Cur = lim.Max
|
||||||
|
Loading…
Reference in New Issue
Block a user