diff options
author | 2021-05-29 19:36:54 +0200 | |
---|---|---|
committer | 2021-05-29 19:36:54 +0200 | |
commit | 0fe853b1ee644703e2273ed4ce331cfd377af268 (patch) | |
tree | 4ada75ed683fa5ed302957c61aa91f4cf409ca01 /internal/federation/federatingdb/lock.go | |
parent | federate account updates (diff) | |
download | gotosocial-0fe853b1ee644703e2273ed4ce331cfd377af268.tar.xz |
first implementation of search feature
Diffstat (limited to 'internal/federation/federatingdb/lock.go')
-rw-r--r-- | internal/federation/federatingdb/lock.go | 7 |
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 { |