aboutsummaryrefslogtreecommitdiffstats
path: root/api/graphql/models/lazy_identity.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2022-06-06 12:53:23 +0200
committerGitHub <noreply@github.com>2022-06-06 12:53:23 +0200
commitc2d7b1271f9dc2df3a752b73bc7fd26dbeeb10c0 (patch)
tree509330a0efa3066d6c17e07a1aa1fe3dcc5abc17 /api/graphql/models/lazy_identity.go
parent96327c3371ca762d906209c6114092bbf552c0f4 (diff)
parentfe231231c68e1f117b6018e008d6d09812604043 (diff)
downloadgit-bug-c2d7b1271f9dc2df3a752b73bc7fd26dbeeb10c0.tar.gz
Merge pull request #811 from MichaelMure/fix-data-race
graphql: fix two invalid mutex lock leading to data races
Diffstat (limited to 'api/graphql/models/lazy_identity.go')
-rw-r--r--api/graphql/models/lazy_identity.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/api/graphql/models/lazy_identity.go b/api/graphql/models/lazy_identity.go
index 002c38e4..451bdd54 100644
--- a/api/graphql/models/lazy_identity.go
+++ b/api/graphql/models/lazy_identity.go
@@ -41,13 +41,13 @@ func NewLazyIdentity(cache *cache.RepoCache, excerpt *cache.IdentityExcerpt) *la
}
func (li *lazyIdentity) load() (*cache.IdentityCache, error) {
+ li.mu.Lock()
+ defer li.mu.Unlock()
+
if li.id != nil {
return li.id, nil
}
- li.mu.Lock()
- defer li.mu.Unlock()
-
id, err := li.cache.ResolveIdentity(li.excerpt.Id)
if err != nil {
return nil, fmt.Errorf("cache: missing identity %v", li.excerpt.Id)