Skip to content

Pull: only close temporary file once#21676

Merged
vdemeester merged 1 commit intomoby:masterfrom
aaronlehmann:tmpfile-close
Mar 31, 2016
Merged

Pull: only close temporary file once#21676
vdemeester merged 1 commit intomoby:masterfrom
aaronlehmann:tmpfile-close

Conversation

@aaronlehmann
Copy link
Copy Markdown

This fixes the problem by setting to ld.tmpFile to nil when the download
completes sucessfully. Then the call to ld.Close will have no effect,
and only the download manager will close the temporary file when it's
done extracting the layer from it. ld.Close will be responsible for
closing the file if we hit the retry limit and there is still a partial
download present.

Fixes #21675

Comment thread distribution/pull_v1.go Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You probably shouldn't return nil here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed, thanks.

Close could be called twice on a temporary download file, which could
have bad side effects.

This fixes the problem by setting to ld.tmpFile to nil when the download
completes sucessfully. Then the call to ld.Close will have no effect,
and only the download manager will close the temporary file when it's
done extracting the layer from it. ld.Close will be responsible for
closing the file if we hit the retry limit and there is still a partial
download present.

Fixes moby#21675

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
@runcom
Copy link
Copy Markdown
Member

runcom commented Mar 31, 2016

LGTM

@vdemeester
Copy link
Copy Markdown
Member

LGTM 🐧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Download manager can close the same file twice

6 participants