From b41491e2c2fd697cd7c20e3a8ca073611b1bffae Mon Sep 17 00:00:00 2001 From: Cory Slep Date: Tue, 19 Feb 2019 20:33:42 +0100 Subject: [PATCH] Add missing Unlock calls. --- pub/side_effect_actor.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pub/side_effect_actor.go b/pub/side_effect_actor.go index d227104..a69d85f 100644 --- a/pub/side_effect_actor.go +++ b/pub/side_effect_actor.go @@ -128,19 +128,26 @@ func (a *sideEffectActor) InboxForwarding(c context.Context, inboxIRI *url.URL, if err != nil { return err } - defer a.db.Unlock(c, id.Get()) + // WARNING: Unlock is not deferred + // // If the database already contains the activity, exit early. exists, err := a.db.Exists(c, id.Get()) if err != nil { + a.db.Unlock(c, id.Get()) return err } else if exists { + a.db.Unlock(c, id.Get()) return nil } // Attempt to create the activity entry. err = a.db.Create(c, activity) if err != nil { + a.db.Unlock(c, id.Get()) return err } + a.db.Unlock(c, id.Get()) + // Unlock by this point and in every branch above. + // // 2. The values of 'to', 'cc', or 'audience' are Collections owned by // this server. var r []*url.URL @@ -413,7 +420,7 @@ func (a *sideEffectActor) addToOutbox(c context.Context, outboxIRI *url.URL, act a.db.Unlock(c, id.Get()) // WARNING: Unlock(c, id) should be called by this point and in every // return before here. - + // // Acquire a lock to read the outbox. Defer release. err = a.db.Lock(c, outboxIRI) if err != nil {