Skip to content

Commit

Permalink
improve flakiness of fs based tests
Browse files Browse the repository at this point in the history
  • Loading branch information
psilva261 committed Jan 17, 2023
1 parent ea0dfe3 commit de519d7
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/syscall/pwd_plan9.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@

package syscall

import "sync"
import (
"runtime"
"sync"
)

var (
wdmu sync.Mutex // guards following
Expand All @@ -20,6 +23,8 @@ var (
)

func Fixwd() {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
wdmu.Lock()
defer wdmu.Unlock()
fixwdLocked()
Expand All @@ -40,6 +45,9 @@ func fixwdLocked() {
}

func fixwd(paths ...string) {
runtime.LockOSThread()
defer runtime.UnlockOSThread()

for _, path := range paths {
if path != "" && path[0] != '/' && path[0] != '#' {
Fixwd()
Expand All @@ -59,6 +67,8 @@ func getwd() (wd string, err error) {
}

func Getwd() (wd string, err error) {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
wdmu.Lock()
defer wdmu.Unlock()

Expand All @@ -75,6 +85,8 @@ func Getwd() (wd string, err error) {
}

func Chdir(path string) error {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
fixwd(path)
wdmu.Lock()
defer wdmu.Unlock()
Expand Down

0 comments on commit de519d7

Please sign in to comment.