Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fd leak and error handling #33713

Merged
merged 1 commit into from
Jul 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions daemon/logger/jsonfilelog/multireader/multireader.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ func (r *multiReadSeeker) Seek(offset int64, whence int) (int64, error) {
rdrOffset := offset - tmpOffset
idx := i

rdr.Seek(rdrOffset, os.SEEK_SET)
if _, err := rdr.Seek(rdrOffset, os.SEEK_SET); err != nil {
return -1, err
}
// make sure all following readers are at 0
for _, rdr := range r.readers[i+1:] {
rdr.Seek(0, os.SEEK_SET)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this one need an error check as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think errors should be ignored and continue the for loop, so maybe no need to check here.

Expand All @@ -67,7 +69,9 @@ func (r *multiReadSeeker) Seek(offset int64, whence int) (int64, error) {
}
tmpOffset += s
}
r.Seek(tmpOffset+offset, os.SEEK_SET)
if _, err := r.Seek(tmpOffset+offset, os.SEEK_SET); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than calling Seek recursively here, which seems to do a lot of redundant work, couldn't we just set r.pos directly?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping @x1022as

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aaronlehmann @vieux if this is an important fix, and we want it to be in 17.07, perhaps we should carry to make sure it gets merged in time

return -1, err
}
return tmpOffset + offset, nil
case os.SEEK_CUR:
if r.pos == nil {
Expand Down
1 change: 1 addition & 0 deletions layer/filestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ func (fms *fileMetadataStore) TarSplitReader(layer ChainID) (io.ReadCloser, erro
}
f, err := gzip.NewReader(fz)
if err != nil {
fz.Close()
return nil, err
}

Expand Down