diff --git a/auth/store/store.go b/auth/store/store.go index e2238d7c2b211dd3923746025ec8488aecf5d493..5a42a0aa9cf2d356c62a4d23189746c16ef90349 100644 --- a/auth/store/store.go +++ b/auth/store/store.go @@ -242,8 +242,9 @@ func (s *Store) HandleReceivedRequest(partner *id.ID, handler func(*ReceivedRequ s.mux.RLock() rr, ok := s.receivedByID[*partner] + s.mux.RUnlock() + if !ok { - s.mux.RUnlock() return errors.Errorf("Received request not "+ "found: %s", partner) } @@ -252,8 +253,17 @@ func (s *Store) HandleReceivedRequest(partner *id.ID, handler func(*ReceivedRequ rr.mux.Lock() defer rr.mux.Unlock() + // Check that the request still exists; it could have been deleted while the + // lock was taken + s.mux.RLock() + _, ok = s.receivedByID[*partner] s.mux.RUnlock() + if !ok { + return errors.Errorf("Received request not "+ + "found: %s", partner) + } + //run the handler handleErr := handler(rr) if handleErr != nil { diff --git a/go.mod b/go.mod index fa815c2b5b6203c9e57afe3f6d8840b1462f1098..708f9615ebea042b51e94b480f79415f4522720c 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ require ( github.com/cloudflare/circl v1.2.0 github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 github.com/golang/protobuf v1.5.2 - github.com/hack-pad/go-indexeddb v0.2.0 github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 github.com/pkg/errors v0.9.1 github.com/pkg/profile v1.6.0 @@ -33,6 +32,7 @@ require ( github.com/badoux/checkmail v1.2.1 // indirect github.com/elliotchance/orderedmap v1.4.0 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect + github.com/hack-pad/go-indexeddb v0.2.0 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/klauspost/cpuid/v2 v2.1.0 // indirect