Increase open file (fd) limit if possible

This will decrease the risk of running out of file descriptors for the
database and other bad things, which could otherwise potentially happen
if we're serving lots of requests and scanning in parallel, etc.

Windows doesn't have a per process open file limit like Unix so we don't
need to worry about it there.
This commit is contained in:
Jakob Borg
2015-08-15 15:20:58 +02:00
parent 5e5eb9bf8e
commit 1c9513e770
3 changed files with 69 additions and 0 deletions

View File

@@ -454,6 +454,11 @@ func syncthingMain() {
runtime.GOMAXPROCS(runtime.NumCPU())
}
// Attempt to increase the limit on number of open files to the maximum
// allowed, in case we have many peers. We don't really care enough to
// report the error if there is one.
osutil.MaximizeOpenFileLimit()
// Ensure that that we have a certificate and key.
cert, err := tls.LoadX509KeyPair(locations[locCertFile], locations[locKeyFile])
if err != nil {