diff options
Diffstat (limited to 'vendor/github.com/containernetworking/plugins')
-rw-r--r-- | vendor/github.com/containernetworking/plugins/pkg/ns/ns_linux.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/vendor/github.com/containernetworking/plugins/pkg/ns/ns_linux.go b/vendor/github.com/containernetworking/plugins/pkg/ns/ns_linux.go index a34f97170..3b745d491 100644 --- a/vendor/github.com/containernetworking/plugins/pkg/ns/ns_linux.go +++ b/vendor/github.com/containernetworking/plugins/pkg/ns/ns_linux.go @@ -26,6 +26,11 @@ import ( // Returns an object representing the current OS thread's network namespace func GetCurrentNS() (NetNS, error) { + // Lock the thread in case other goroutine executes in it and changes its + // network namespace after getCurrentThreadNetNSPath(), otherwise it might + // return an unexpected network namespace. + runtime.LockOSThread() + defer runtime.UnlockOSThread() return GetNS(getCurrentThreadNetNSPath()) } |