diff options
author | Michael Muré <batolettre@gmail.com> | 2022-06-06 12:53:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-06 12:53:23 +0200 |
commit | c2d7b1271f9dc2df3a752b73bc7fd26dbeeb10c0 (patch) | |
tree | 509330a0efa3066d6c17e07a1aa1fe3dcc5abc17 /api/graphql/models/lazy_identity.go | |
parent | 96327c3371ca762d906209c6114092bbf552c0f4 (diff) | |
parent | fe231231c68e1f117b6018e008d6d09812604043 (diff) | |
download | git-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.go | 6 |
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) |