mirror of
https://github.com/aler9/rtsp-simple-server
synced 2025-10-21 14:49:36 +08:00
try to raise the number of file descriptors that can be opened to remove limits on number of connected clients (#193)
This commit is contained in:
29
internal/rlimit/rlimit_unix.go
Normal file
29
internal/rlimit/rlimit_unix.go
Normal file
@@ -0,0 +1,29 @@
|
||||
// +build !windows
|
||||
|
||||
package rlimit
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// Raise raises the number of file descriptors that can be opened.
|
||||
func Raise() error {
|
||||
var rlim syscall.Rlimit
|
||||
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlim)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rlim.Cur = 999999
|
||||
err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlim)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user