mirror of
https://github.com/golang/go
synced 2024-09-04 23:44:16 +00:00
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/21137 Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
parent
4d920410d2
commit
1664ff96f7
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue