Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4ae119c1 authored by Liz Kammer's avatar Liz Kammer
Browse files

In Soong, set max files soft limit to hard limit

Test: m nothing
Change-Id: I4f45ebcf8c7b74315c371012603aeb7c541ae336
parent 948c3401
Loading
Loading
Loading
Loading
+22 −8
Original line number Original line Diff line number Diff line
@@ -205,14 +205,7 @@ func main() {
	buildCtx.Verbosef("Parallelism (local/remote/highmem): %v/%v/%v",
	buildCtx.Verbosef("Parallelism (local/remote/highmem): %v/%v/%v",
		config.Parallel(), config.RemoteParallel(), config.HighmemParallel())
		config.Parallel(), config.RemoteParallel(), config.HighmemParallel())


	{
	setMaxFiles(buildCtx)
		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)
	}


	{
	{
		// The order of the function calls is important. The last defer function call
		// 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)
	}
}