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

Add an extra set of state tracking for Timeout.timeout edge cases #194

Merged
merged 1 commit into from
Mar 30, 2015

Conversation

zanker
Copy link
Contributor

@zanker zanker commented Mar 29, 2015

Thoughts? This isn't strictly necessary, as the chance of this happening is very very small. It is still a chance though.

Normally, Timeout.timeout raises an exception and kills the block and everything is handy dandy. In rare situations, it will raise and then kill execution while the rescue block executes (see mperham/connection_pool#67 for more info).

This adds an extra layer of protection, where if we run into that, we reset the connection anyway.

@@ -98,6 +103,11 @@ def verify_connection!(uri)
# lazily load the body as long as possible, and this mimics prior functionality.
elsif @connection && (!@connection.keep_alive? || @connection.expired?)
close

Copy link
Member

Choose a reason for hiding this comment

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

Why do you add this extra line? :D

Copy link
Member

Choose a reason for hiding this comment

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

I mean, can you try to avoid it? :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I find it makes it harder to read personally, but I don't really care either way.

@tarcieri
Copy link
Member

Seems ugly but so does Timeout 😜 In absence of a fully asynchronous timeout scheme this seems ok to me.

@zanker
Copy link
Contributor Author

zanker commented Mar 29, 2015

Yea it's not great unfortunately but such is life :(

@@ -93,11 +98,14 @@ def close
def verify_connection!(uri)
if default_options.persistent? && base_host(uri) != default_options.persistent
fail StateError, "Persistence is enabled for #{default_options.persistent}, but we got #{base_host(uri)}"

Copy link
Member

Choose a reason for hiding this comment

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

Thanks! 🙇

@sferik sferik added this to the v0.8 milestone Mar 30, 2015
zanker added a commit that referenced this pull request Mar 30, 2015
Add an extra set of state tracking for Timeout.timeout edge cases
@zanker zanker merged commit 30e37ce into httprb:master Mar 30, 2015
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