Commit a78fb6d7 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Increase file descriptor limit at startup.

parent 82b10b2c
...@@ -15,6 +15,7 @@ import ( ...@@ -15,6 +15,7 @@ import (
"github.com/jech/galene/diskwriter" "github.com/jech/galene/diskwriter"
"github.com/jech/galene/group" "github.com/jech/galene/group"
"github.com/jech/galene/ice" "github.com/jech/galene/ice"
"github.com/jech/galene/limit"
"github.com/jech/galene/turnserver" "github.com/jech/galene/turnserver"
"github.com/jech/galene/webserver" "github.com/jech/galene/webserver"
) )
...@@ -104,6 +105,13 @@ func main() { ...@@ -104,6 +105,13 @@ func main() {
}() }()
} }
n, err := limit.Nofile(0xFFFF)
if err != nil {
log.Printf("Couldn't set file descriptor limit: %v", err)
} else if n < 0xFFFF {
log.Printf("File descriptor limit is %v, please increase it!", n)
}
ice.ICEFilename = filepath.Join(dataDir, "ice-servers.json") ice.ICEFilename = filepath.Join(dataDir, "ice-servers.json")
go group.ReadPublicGroups() go group.ReadPublicGroups()
......
...@@ -13,4 +13,5 @@ require ( ...@@ -13,4 +13,5 @@ require (
github.com/pion/turn/v2 v2.0.5 github.com/pion/turn/v2 v2.0.5
github.com/pion/webrtc/v3 v3.0.31 github.com/pion/webrtc/v3 v3.0.31
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c
) )
...@@ -122,8 +122,9 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w ...@@ -122,8 +122,9 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
......
// +build windows plan9
package limit
func Nofile(desired uint64) (uint64, error) {
return desired, nil
}
// +build !windows
// +build !plan9
package limit
import (
"golang.org/x/sys/unix"
)
func Nofile(desired uint64) (uint64, error) {
var old unix.Rlimit
err := unix.Getrlimit(unix.RLIMIT_NOFILE, &old)
if err != nil {
return 0, err
}
if old.Cur >= desired {
return old.Cur, nil
}
if old.Max < desired {
limit := unix.Rlimit{
Cur: desired,
Max: desired,
}
err := unix.Setrlimit(unix.RLIMIT_NOFILE, &limit)
if err == nil {
return limit.Cur, nil
}
desired = old.Max
}
limit := unix.Rlimit{
Cur: desired,
Max: old.Max,
}
err = unix.Setrlimit(unix.RLIMIT_NOFILE, &limit)
if err != nil {
return old.Cur, err
}
return limit.Cur, nil
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment