Permalink
Browse files

blobserver/files: fix a data race in os.FileInfo stat readahead

And fix some log messages to remove "localdisk", since this code is
now shared by sftp and in the future will be shared by webdav, ftps,
etc.

Change-Id: I4c428cdd6c90bb509045d1914922326a10f48a17
(cherry picked from commit d50667a)
  • Loading branch information...
bradfitz committed May 9, 2018
1 parent fcba46d commit 1c0648653102b62baf22d7cf054548bd68f4e3f5
Showing with 7 additions and 3 deletions.
  1. +7 −3 pkg/blobserver/files/enumerate.go
@@ -45,7 +45,7 @@ type enumerateError struct {
}
func (ee *enumerateError) Error() string {
return fmt.Sprintf("localdisk enumerate error: %s: %v", ee.msg, ee.err)
return fmt.Sprintf("files enumerate error: %s: %v", ee.msg, ee.err)
}
// readBlobs implements EnumerateBlobs. It calls itself recursively on subdirectories.
@@ -80,7 +80,7 @@ func (ds *Storage) readBlobs(ctx context.Context, opts readBlobRequest) error {
return fi, nil
})
stat[name] = f
toStat = append(toStat, f.run)
toStat = append(toStat, f.ForceLoad)
}
// Start pre-statting things.
@@ -168,7 +168,7 @@ func (ds *Storage) readBlobs(ctx context.Context, opts readBlobRequest) error {
func (ds *Storage) EnumerateBlobs(ctx context.Context, dest chan<- blob.SizedRef, after string, limit int) error {
defer close(dest)
if limit == 0 {
log.Printf("Warning: localdisk.EnumerateBlobs called with a limit of 0")
log.Printf("Warning: files.EnumerateBlobs called with a limit of 0")
}
limitMutable := limit
@@ -213,4 +213,8 @@ func (f *future) Get() (os.FileInfo, error) {
return f.v, f.err
}
func (f *future) ForceLoad() {
f.Get()
}
func (f *future) run() { f.v, f.err = f.f() }

0 comments on commit 1c06486

Please sign in to comment.