зеркало из https://github.com/golang/tools.git
internal/lsp/cache: lock in snapshot.knownFilesInDir
We were not locking while iterating s.files in snapshot.knownFilesInDir. All other accesses of s.files appear to be locked, so this should fix golang/go#43972. Fixes golang/go#43972 Change-Id: I01184c3992c91f8beb4a3239f70cc4487a528ec0 Reviewed-on: https://go-review.googlesource.com/c/tools/+/287573 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Rebecca Stambler <rstambler@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
Родитель
c2bea79de9
Коммит
f871472f1b
|
@ -32,7 +32,6 @@ import (
|
|||
"golang.org/x/tools/internal/packagesinternal"
|
||||
"golang.org/x/tools/internal/span"
|
||||
"golang.org/x/tools/internal/typesinternal"
|
||||
"golang.org/x/xerrors"
|
||||
errors "golang.org/x/xerrors"
|
||||
)
|
||||
|
||||
|
@ -718,6 +717,9 @@ func (s *snapshot) allKnownSubdirs(ctx context.Context) map[span.URI]struct{} {
|
|||
// the given directory. It does not respect symlinks.
|
||||
func (s *snapshot) knownFilesInDir(ctx context.Context, dir span.URI) []span.URI {
|
||||
var files []span.URI
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
|
||||
for uri := range s.files {
|
||||
if source.InDir(dir.Filename(), uri.Filename()) {
|
||||
files = append(files, uri)
|
||||
|
@ -1010,7 +1012,7 @@ func (s *snapshot) awaitLoaded(ctx context.Context) error {
|
|||
|
||||
func (s *snapshot) GetCriticalError(ctx context.Context) *source.CriticalError {
|
||||
loadErr := s.awaitLoadedAllErrors(ctx)
|
||||
if xerrors.Is(loadErr, context.Canceled) {
|
||||
if errors.Is(loadErr, context.Canceled) {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче