Browse Source

Fix wrong type for syscall.Setrlimit on FreeBSD (#244)

Values are uint64 on Unix but FreeBSD uses int64 for legacy reasons.
pull/265/head
Simon Eisenmann 10 years ago
parent
commit
6920fcc891
  1. 6
      src/app/spreed-webrtc-server/main.go
  2. 11
      src/app/spreed-webrtc-server/types_freebsd.go
  3. 8
      src/app/spreed-webrtc-server/types_unix.go

6
src/app/spreed-webrtc-server/main.go

@ -367,13 +367,13 @@ func runner(runtime phoenix.Runtime) error { @@ -367,13 +367,13 @@ func runner(runtime phoenix.Runtime) error {
// Try to increase number of file open files. This only works as root.
maxfd, err := runtime.GetInt("http", "maxfd")
if err == nil {
rLimit.Max = uint64(maxfd)
rLimit.Cur = uint64(maxfd)
rLimit.Max = rlimitType(maxfd)
rLimit.Cur = rlimitType(maxfd)
err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
log.Println("Error setting max open files", err)
} else {
log.Printf("Set max open files successfully to %d\n", uint64(maxfd))
log.Printf("Set max open files successfully to %d\n", rlimitType(maxfd))
}
}

11
src/app/spreed-webrtc-server/types_freebsd.go

@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
// +build freebsd
package main
// Rlimit values are int64 in FreeBSD.
// https://golang.org/src/syscall/ztypes_freebsd_amd64.go
// Intentionally signed, because of legacy code that uses -1 for
// RLIM_INFINITY.
func rlimitType(value int) int64 {
return int64(value)
}

8
src/app/spreed-webrtc-server/types_unix.go

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
// +build !freebsd
package main
// On Unix, rLimit values are uint64.
func rlimitType(value int) uint64 {
return uint64(value)
}
Loading…
Cancel
Save