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

fix(rt): enforce only once shutdown logic for crt engine connections #497

Merged
merged 3 commits into from
Jan 11, 2022

Conversation

aajtodd
Copy link
Collaborator

@aajtodd aajtodd commented Jan 10, 2022

Issue #

fixes #413

Description of changes

Fixes the segfault that can happen when an exception is handled twice leading to a connection being closed after it has been free'd. This change refactors the handling of the connection close logic to be handled in a single place regardless of why the connection is being closed.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

fixes: #413

Fixes the segfault that can happen when an exception is handled twice
leading to a connection being closed after it has been free'd. This
change refactors the handling of the connection close logic to be
handled in a single place regardless of why the connection is being
closed.
@aajtodd aajtodd requested a review from a team as a code owner January 10, 2022 17:56
@github-actions
Copy link

A new generated diff is ready to view: __generated-main...__generated-fix-413

@github-actions
Copy link

A new generated diff is ready to view: __generated-main...__generated-fix-413

val forceClose = !streamCompleted

if (forceClose) {
logger.trace { "stream did not complete before job, forcing connection shutdown! handler=$this; conn=$conn; stream=$crtStream" }
Copy link
Contributor

Choose a reason for hiding this comment

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

comment

Perhaps this should be a higher level message, like warn. From past experience it is often useful to know when partial results where received.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This doesn't necessarily mean partial results though. Technically it just means the coroutine job completed before consuming the entire response which could happen because of an exception or simply because the consumer doesn't read the entire body.

If we actually had a stream cancellation API then we wouldn't need to force close the connection which would make this less heavy handed.

I don't think I'd make it warn because in the case of an exception they'll be forced to handle it anyway and the exception is your signal. In the case of explicitly not consuming the entire body it's not a warning since the consumer is choosing it. Perhaps debug would be better than trace though?

@sonarcloud
Copy link

sonarcloud bot commented Jan 11, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@github-actions
Copy link

A new generated diff is ready to view: __generated-main...__generated-fix-413

@aajtodd aajtodd merged commit df3d15a into main Jan 11, 2022
@aajtodd aajtodd deleted the fix-413 branch January 11, 2022 20:10
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.

Segfault in CRT HTTP engine connection shutdown
3 participants