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..6a6a0ee9c1351629556cb1313ec756c96dfb447a |
| --- /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 { |
| + if _, err := os.Stat(path); os.IsNotExist(err) { |
|
iannucci
2017/07/11 20:52:15
tbh, I would probably not stat, I'd just bail on E
charliea (OOO until 10-5)
2017/07/11 23:26:16
The actual lock implementation accepts an already-
|
| + return fmt.Errorf("cannot acquire lock on %s because file does not exist", path) |
| + } |
| + |
| + // TODO(charliea): Acquire the actual lock. |
|
iannucci
2017/07/11 20:52:14
can also `panic("implement lock acquisition")`
charliea (OOO until 10-5)
2017/07/11 23:26:16
Done.
|
| + return nil |
| +} |