Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix race condition in GetCurrentNS temporarily (antrea-io#1131)
In GetCurrentNS, If there is a context-switch between getCurrentThreadNetNSPath and GetNS, another goroutine may execute in the original thread and change its network namespace, then the original goroutine would get the updated network namespace, which could lead to unexpected behavior, especially when GetCurrentNS is used to get the host network namespace in netNS.Do. Instead of using the provided netns argument, this patch fixes it by getting the hostNS in advance with the OS thread locked.
- Loading branch information