Skip to content

fix: avoid throwing exception in destructor #146

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

Closed
wants to merge 1 commit into from

Conversation

metahys
Copy link

@metahys metahys commented Jan 28, 2022

When data compression is enabled, CompressedOutput will be created in Client::Impl::SendData. If the socket is unfortunately broken during the execution of SocketOutput::DoWrite, a std::system_error exception will be thrown. Next, the destructor of CompressedOutput will be called during stack unwinding, and then Flush() in ~CompressedOutput will call SocketOutput::DoWrite again, eventually causing the program to terminate.

@CLAassistant
Copy link

CLAassistant commented Jan 28, 2022

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@Enmk Enmk left a comment

Choose a reason for hiding this comment

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

IMO it is better to remove Flush() from destructor altogether and make it a caller's responsibility to explicitly call Flush() as a happy-path. In this case all errors that arise are visible to the library user and no need to hide those.

@Enmk Enmk mentioned this pull request Feb 7, 2022
@Enmk Enmk closed this in #150 Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants