summaryrefslogtreecommitdiff
path: root/internal/federation/federatingdb/lock.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/federation/federatingdb/lock.go')
-rw-r--r--internal/federation/federatingdb/lock.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/internal/federation/federatingdb/lock.go b/internal/federation/federatingdb/lock.go
index 417fd79b2..c9062da89 100644
--- a/internal/federation/federatingdb/lock.go
+++ b/internal/federation/federatingdb/lock.go
@@ -42,6 +42,10 @@ func (f *federatingDB) Lock(c context.Context, id *url.URL) error {
// Strategy: create a new lock, if stored, continue. Otherwise, lock the
// existing mutex.
+ if id == nil {
+ return errors.New("Lock: id was nil")
+ }
+
mu := &sync.Mutex{}
mu.Lock() // Optimistically lock if we do store it.
i, loaded := f.locks.LoadOrStore(id.String(), mu)
@@ -59,6 +63,9 @@ func (f *federatingDB) Lock(c context.Context, id *url.URL) error {
func (f *federatingDB) Unlock(c context.Context, id *url.URL) error {
// Once Go-Fed is done calling Database methods, the relevant `id`
// entries are unlocked.
+ if id == nil {
+ return errors.New("Unlock: id was nil")
+ }
i, ok := f.locks.Load(id.String())
if !ok {