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

TarReader should dispose underlying stream if leaveOpen is false #79899

Merged

Conversation

jozkee
Copy link
Member

@jozkee jozkee commented Dec 22, 2022

Potentially fixes #77012.

@jozkee jozkee added this to the 8.0.0 milestone Dec 22, 2022
@jozkee jozkee requested review from carlossanlop, adamsitnik and a team December 22, 2022 03:56
@ghost ghost assigned jozkee Dec 22, 2022
@build-analysis build-analysis bot mentioned this pull request Dec 22, 2022
Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

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

LGTM, thank you for a quick fix @jozkee !

@adamsitnik adamsitnik merged commit 5090041 into dotnet:main Dec 22, 2022
@akoeplinger
Copy link
Member

should this be backported?

@jozkee jozkee deleted the tarreader_leaveopen_false_should_dispose branch December 22, 2022 17:26
akoeplinger added a commit to akoeplinger/runtime that referenced this pull request Dec 22, 2022
adamsitnik pushed a commit that referenced this pull request Dec 23, 2022
* Dispose underlying stream in TarReader.DisposeAsync() as well

Same as #79899

* Consolidate duplicated WrappedStream test helpers to Common sources

* Dispose stream passed to WrappedStream
{
foreach (Stream s in _dataStreamsToDispose)
_archiveStream.Dispose();
Copy link
Member

Choose a reason for hiding this comment

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

What's the relationship between the streams in _dataStreamsToDispose and _archiveStream? Do the former streams wrap the latter? I'm wondering if the archive stream should actually be disposed of after rather than before the _dataStreamsToDispose.

Copy link
Member

@carlossanlop carlossanlop Jan 3, 2023

Choose a reason for hiding this comment

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

The code change is correct incorrect: The archive stream represents the whole tar archive, while the data streams represent sub-sections of the archive, each wrapping only the data section of an individual entry.

This means that all the individual data streams need to get disposed first, and the archive stream needs to be disposed at the end.

Edit: I see my mistake, I misread the diff.

Copy link
Member Author

Choose a reason for hiding this comment

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

This means that all the individual data streams need to get disposed first, and the archive stream needs to be disposed at the end.

This is the opposite of what I did here. @carlossanlop shall we fix it?

Copy link
Member

Choose a reason for hiding this comment

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

Yes.

jozkee added a commit to jozkee/runtime that referenced this pull request Jan 13, 2023
jozkee pushed a commit to jozkee/runtime that referenced this pull request Jan 13, 2023
…#79920)

* Dispose underlying stream in TarReader.DisposeAsync() as well

Same as dotnet#79899

* Consolidate duplicated WrappedStream test helpers to Common sources

* Dispose stream passed to WrappedStream
carlossanlop pushed a commit that referenced this pull request Jan 13, 2023
… is false (#80598)

* TarReader should dispose underlying stream if leaveOpen is false (#79899)

* Dispose underlying stream in TarReader.DisposeAsync() as well (#79920)

* Dispose underlying stream in TarReader.DisposeAsync() as well

Same as #79899

* Consolidate duplicated WrappedStream test helpers to Common sources

* Dispose stream passed to WrappedStream

* Dispose archive stream after the list of DataStreams (#80572)

* Dispose archive stream after the list of DataStreams

* Add tests for TarReader.DisposeAsync properly disposing underlying stream

Co-authored-by: Alexander Köplinger <[email protected]>
@ghost ghost locked as resolved and limited conversation to collaborators Feb 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TarWriter_WriteEntry_LongFile_Tests require 104GB free
5 participants