mirror of
https://github.com/golang/go
synced 2024-11-18 19:14:40 -07:00
internal/lsp: fix race in checkPackageHandles
We were caching the package before setting the handle, so a checkPackageHandle might be in use before it was fully created. Change-Id: Ic98e7c351cbed5e4caa87098e95ad04d4f54f8df Reviewed-on: https://go-review.googlesource.com/c/tools/+/202040 Run-TryBot: Rebecca Stambler <rstambler@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
0bbdbb2ef6
commit
a1005cf9b2
6
internal/lsp/cache/check.go
vendored
6
internal/lsp/cache/check.go
vendored
@ -99,6 +99,9 @@ func (imp *importer) checkPackageHandle(ctx context.Context, id packageID) (*che
|
||||
})
|
||||
cph.handle = h
|
||||
|
||||
// Cache the CheckPackageHandle in the snapshot.
|
||||
imp.snapshot.addPackage(cph)
|
||||
|
||||
return cph, nil
|
||||
}
|
||||
|
||||
@ -147,9 +150,6 @@ func (imp *importer) buildKey(ctx context.Context, id packageID, mode source.Par
|
||||
}
|
||||
cph.key = checkPackageKey(cph.m.id, cph.files, m.config, depKeys)
|
||||
|
||||
// Cache the CheckPackageHandle in the snapshot.
|
||||
imp.snapshot.addPackage(cph)
|
||||
|
||||
return cph, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user