Skip to content

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Sep 14, 2023

This is required for #28052, but makes sense on its own, because offloading logic to CAutoFile instead of re-implementing it allows to delete code and complexity.

@DrahtBot
Copy link
Contributor

DrahtBot commented Sep 14, 2023

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK TheCharlatan, willcl-ark

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #28052 (blockstorage: XOR blocksdir *.dat files by MarcoFalke)
  • #24230 (indexes: Stop using node internal types and locking cs_main, improve sync logic by ryanofsky)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@DrahtBot DrahtBot changed the title refactor: Return CAutoFile from BlockManager::Open*File() refactor: Return CAutoFile from BlockManager::Open*File() Sep 14, 2023
Copy link
Contributor

@TheCharlatan TheCharlatan left a comment

Choose a reason for hiding this comment

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

ACK fa33b6f


// Disallow copies
BufferedFile(const BufferedFile&) = delete;
BufferedFile& operator=(const BufferedFile&) = delete;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Would removing this in the second commit when the FILE * is changed to CAutoFile make more sense?

Copy link
Member Author

Choose a reason for hiding this comment

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

Now that fclose is removed, copies are allowed, because they no longer lead to a double-free undefined behavior segfault (Calling fclose twice on the same pointer)

MarcoFalke added 3 commits September 15, 2023 14:33
This was only explicitly used in the tests, where it can be replaced by
wrapping the original raw file pointer into a CAutoFile on creation and
then calling CAutoFile::fclose().

Also, it was used in LoadExternalBlockFile(), where it can also be
replaced by the (implicit call to the) CAutoFile destructor after
wrapping the original raw file pointer in a CAutoFile.
This refactor allows to forward some calls to the underlying CAutoFile,
instead of re-implementing the logic in the buffered file.
@maflcko maflcko force-pushed the 2309-rework-block-file- branch from fa33b6f to fa56c42 Compare September 15, 2023 12:37
Copy link
Contributor

@TheCharlatan TheCharlatan left a comment

Choose a reason for hiding this comment

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

Re-ACK fa56c42

Just addressing nits.

@fanquake fanquake requested a review from stickies-v September 16, 2023 11:05
Copy link
Member

@willcl-ark willcl-ark left a comment

Choose a reason for hiding this comment

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

tACK fa56c42

Clean refactor needed for future work.

@fanquake fanquake merged commit c9f2882 into bitcoin:master Sep 26, 2023
Frank-GER pushed a commit to syscoin/syscoin that referenced this pull request Sep 27, 2023
@maflcko maflcko deleted the 2309-rework-block-file- branch September 28, 2023 08:30
@bitcoin bitcoin locked and limited conversation to collaborators Dec 3, 2024
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.

5 participants