Commit 1664ff96 authored by Elias Naur's avatar Elias Naur

misc/ios: fix exec wrapper locking

The exec wrapper lock file was opened, locked and then never used
again, assuming it would close and unlock at process exit.
However, the garbage collector could collect and run the *os.File
finalizer that closes the file prematurely, rendering the lock
ineffective.

Make the lock global so that the lock is live during the entire
execution.

(Hopefully) fix the iOS builders.

Change-Id: I62429e92042a0a49c4f1ea553fdb32b6ea53a43e
Reviewed-on: https://go-review.googlesource.com/21137Reviewed-by: default avatarDavid Crawshaw <crawshaw@golang.org>
parent 4d920410
......@@ -50,6 +50,11 @@ var (
teamID string
)
// lock is a file lock to serialize iOS runs. It is global to avoid the
// garbage collector finalizing it, closing the file and releasing the
// lock prematurely.
var lock *os.File
func main() {
log.SetFlags(0)
log.SetPrefix("go_darwin_arm_exec: ")
......@@ -84,7 +89,7 @@ func main() {
// The lock file is never deleted, to avoid concurrent locks on distinct
// files with the same path.
lockName := filepath.Join(os.TempDir(), "go_darwin_arm_exec.lock")
lock, err := os.OpenFile(lockName, os.O_CREATE|os.O_RDONLY, 0666)
lock, err = os.OpenFile(lockName, os.O_CREATE|os.O_RDONLY, 0666)
if err != nil {
log.Fatal(err)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment