Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(766)

Unified Diff: mmutex/lib/flock.go

Issue 2980603003: Flesh out the mmutex binary wrapper and test for existence of lockfile (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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")
+}

Powered by Google App Engine
This is Rietveld 408576698