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 connection keep-alive for request-response. #1700

Merged
merged 3 commits into from
Aug 13, 2020

Conversation

romanb
Copy link
Contributor

@romanb romanb commented Aug 13, 2020

Upon reviewing #1698 I double-checked the analogous handling in request-response which seemed to lack a condition, resulting in an indefinite keep-alive. More generally and judging from prior experience from other handlers where the keep-alive handling has been tricky to get right, it seems this keep-alive handling may better be done in a more general manner in libp2p-core, for all connection handlers. Not sure yet how realistic that is though.

@@ -313,7 +313,7 @@ where
self.outbound.shrink_to_fit();
}

if self.inbound.is_empty() {
if self.inbound.is_empty() && self.keep_alive.is_yes() {
Copy link
Member

Choose a reason for hiding this comment

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

Paraphrasing this to make sure I am on the same page: Without the additional && self.keep_alive.is_yes() this condition would be triggered on each poll if the inbound queue is empty and thus the self.keep_alive timeout would be refreshed each time leaving it no time to expire. Is that correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is correct.

@romanb romanb merged commit 96484fc into libp2p:master Aug 13, 2020
@romanb romanb deleted the request-response-keepalive branch August 13, 2020 11:13
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.

2 participants