Skip to content

Commit

Permalink
Lock goroutine to OS thread while changing NS
Browse files Browse the repository at this point in the history
Prevents an issue where the goroutine may jump to a new OS thread during
execution putting it into a mount/network NS that is unexpected.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
(cherry picked from commit 65bb58f)
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
  • Loading branch information
cpuguy83 committed Aug 16, 2017
1 parent 860637f commit 97725cd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/overlay/ov_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -81,6 +82,10 @@ func setDefaultVlan() {
logrus.Error("insufficient number of arguments")
os.Exit(1)
}

runtime.LockOSThread()
defer runtime.UnlockOSThread()

nsPath := os.Args[1]
ns, err := netns.GetFromPath(nsPath)
if err != nil {
Expand Down

0 comments on commit 97725cd

Please sign in to comment.