From c918058bb76c880ea56b6430d7a2a629ec47a719 Mon Sep 17 00:00:00 2001 From: lifubang Date: Thu, 16 May 2024 20:34:43 +0800 Subject: [PATCH] fix comments for ClearRlimitNofileCache Signed-off-by: lifubang (cherry picked from commit a35f7d80931192c50ea15d688afd54f45c7fb7fd) Signed-off-by: lifubang --- libcontainer/system/rlimit_go119.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libcontainer/system/rlimit_go119.go b/libcontainer/system/rlimit_go119.go index e3c2efeb1..a68c8ca60 100644 --- a/libcontainer/system/rlimit_go119.go +++ b/libcontainer/system/rlimit_go119.go @@ -12,13 +12,14 @@ import ( //go:linkname syscallOrigRlimitNofile syscall.origRlimitNofile var syscallOrigRlimitNofile atomic.Pointer[syscall.Rlimit] -// As reported in issue #4195, the new version of go runtime(since 1.19) -// will cache rlimit-nofile. Before executing execve, the rlimit-nofile -// of the process will be restored with the cache. In runc, this will -// cause the rlimit-nofile setting by the parent process for the container -// to become invalid. It can be solved by clearing this cache. But -// unfortunately, go stdlib doesn't provide such function, so we need to -// link to the private var `origRlimitNofile` in package syscall to hack. +// ClearRlimitNofileCache is to clear go runtime's nofile rlimit cache. func ClearRlimitNofileCache() { + // As reported in issue #4195, the new version of go runtime(since 1.19) + // will cache rlimit-nofile. Before executing execve, the rlimit-nofile + // of the process will be restored with the cache. In runc, this will + // cause the rlimit-nofile setting by the parent process for the container + // to become invalid. It can be solved by clearing this cache. But + // unfortunately, go stdlib doesn't provide such function, so we need to + // link to the private var `origRlimitNofile` in package syscall to hack. syscallOrigRlimitNofile.Store(nil) }