Merge "In Soong, set max files soft limit to hard limit" am: 26cb965d2f
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1978314 Change-Id: Ie6b4ed1c6873c1b96b3869c3bd68fbcc140c6db0
This commit is contained in:
commit
af351356ed
1 changed files with 22 additions and 8 deletions
|
@ -205,14 +205,7 @@ func main() {
|
|||
buildCtx.Verbosef("Parallelism (local/remote/highmem): %v/%v/%v",
|
||||
config.Parallel(), config.RemoteParallel(), config.HighmemParallel())
|
||||
|
||||
{
|
||||
var limits syscall.Rlimit
|
||||
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limits)
|
||||
if err != nil {
|
||||
buildCtx.Verbosef("Failed to get file limit:", err)
|
||||
}
|
||||
buildCtx.Verbosef("Current file limits: %d soft, %d hard", limits.Cur, limits.Max)
|
||||
}
|
||||
setMaxFiles(buildCtx)
|
||||
|
||||
{
|
||||
// The order of the function calls is important. The last defer function call
|
||||
|
@ -614,3 +607,24 @@ func populateExternalDistDirHelper(ctx build.Context, config build.Config, inter
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func setMaxFiles(ctx build.Context) {
|
||||
var limits syscall.Rlimit
|
||||
|
||||
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &limits)
|
||||
if err != nil {
|
||||
ctx.Println("Failed to get file limit:", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Verbosef("Current file limits: %d soft, %d hard", limits.Cur, limits.Max)
|
||||
if limits.Cur == limits.Max {
|
||||
return
|
||||
}
|
||||
|
||||
limits.Cur = limits.Max
|
||||
err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &limits)
|
||||
if err != nil {
|
||||
ctx.Println("Failed to increase file limit:", err)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue