Increase in-process max open files limit

This commit is contained in:
Tomás Senart
2013-08-14 22:27:51 +02:00
parent 0d22f32683
commit 7bf545f5e5

13
main.go
View File

@@ -8,6 +8,7 @@ import (
"net/http"
"os"
"runtime"
"syscall"
"time"
)
@@ -32,6 +33,10 @@ func main() {
return
}
if err := increaseResourceLimits(); err != nil {
log.Fatalf("Couldn't increase resource limits: %s", err)
}
// Validate rate argument
if *rate == 0 {
log.Fatal("rate can't be zero")
@@ -102,3 +107,11 @@ func attack(targets Targets, ordering string, rate uint, duration time.Duration,
rep.Add(<-responses)
}
}
func increaseResourceLimits() error {
limit := &syscall.Rlimit{Cur: syscall.RLIM_INFINITY}
if err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, limit); err != nil {
return err
}
return nil
}