Chromium Code Reviews| Index: mmutex/lib/flock.go |
| diff --git a/mmutex/lib/flock.go b/mmutex/lib/flock.go |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..591a329bf8923c89487df7d30f897d8b3343a5ee |
| --- /dev/null |
| +++ b/mmutex/lib/flock.go |
| @@ -0,0 +1,20 @@ |
| +// Copyright 2017 The LUCI Authors. All rights reserved. |
| +// Use of this source code is governed under the Apache License, Version 2.0 |
| +// that can be found in the LICENSE file. |
| + |
| +package lib |
| + |
| +import ( |
| + "fmt" |
| + "os" |
| +) |
| + |
| +// TODO(charliea): Add timeout parameter to this function. |
| +func AcquireExclusiveLock(path string) error { |
| + _, err := os.OpenFile(path, os.O_APPEND, 0666) |
| + if os.IsNotExist(err) { |
| + return fmt.Errorf("cannot acquire lock on %s because file does not exist", path) |
|
iannucci
2017/07/12 01:34:59
recommend use of luci-go/common/errors (they colle
charliea (OOO until 10-5)
2017/07/12 02:17:17
Done.
|
| + } |
| + |
| + panic("implement lock acquisition") |
| +} |