-
Notifications
You must be signed in to change notification settings - Fork 321
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
Use io/wait on platforms where it's available #283
Conversation
IO.select is an expensive call, because it has to build an fd_set (large bitfield) from an array each time we invoke it. We're just interested in IO readiness, so on Ruby 2.0+ we can use the io/wait API instead, which adds wait_readable/wait_writable to IO objects.
Use io/wait on platforms where it's available
@@ -59,14 +59,17 @@ def write(data) | |||
# Read data from the socket | |||
def readpartial(size) | |||
loop do | |||
result = socket.read_nonblock(size, :exception => false) | |||
result = rescue_readable do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't make sense, there's nothing to rescue since it's not using exceptions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you recall from before, JRuby silently discards :exception => false
on SSL sockets and still throws exceptions. I can add a comment to that effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some clarifying comments in fbb57b5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh right fsss. Yea if you can put a comment please.
Sent from my iPhone
On Dec 26, 2015, at 15:49, Tony Arcieri [email protected] wrote:
In lib/http/timeout/per_operation.rb:
@@ -59,14 +59,17 @@ def write(data)
# Read data from the socket
def readpartial(size)
loop do
result = socket.read_nonblock(size, :exception => false)
If you recall from before, JRuby silently discards :exception => false on SSL sockets and still throws exceptions. I can add a comment to that effect.result = rescue_readable do
—
Reply to this email directly or view it on GitHub.
LGs besides those minor things |
## 1.0.1 (2015-12-27) * [#283](httprb/http#283): Use io/wait on supported platforms. ([@tarcieri]) ## 1.0.0 (2015-12-25) * [#265](httprb/http#265): Remove deprecations ([@tarcieri]): - HTTP::Chainable#with_follow (use #follow) - HTTP::Chainable#with, #with_headers (use #headers) - HTTP::Chainable#auth(:basic, ...) (use #basic_auth) - HTTP::Chainable#default_headers (use #default_options[:headers]) - HTTP::Headers#append (use #add) - HTTP::Options#[] hash-like API deprecated in favor of explicit methods - HTTP::Request#request_header (use #headline) - HTTP::Response::STATUS_CODES (use HTTP::Status::REASONS) - HTTP::Response::SYMBOL_TO_STATUS_CODE (no replacement) - HTTP::Response#status_code (use #status or #code) - HTTP::Response::Status#symbolize (use #to_sym) * [#269](httprb/http#273): Close connection in case of error during request. ([@ixti]) * [#271](httprb/http#273): High-level exception wrappers for low-level I/O errors. ([@ixti]) * [#273](httprb/http#273): Add encoding option. ([@Connorhd]) * [#275](httprb/http#273): Support for disabling Nagle's algorithm with `HTTP.nodelay`. ([@nerdrew]) * [#276](httprb/http#276) Use Encoding::BINARY as the default encoding for HTTP::Response::Body. ([@tarcieri]) * [#278](httprb/http#278) Use an options hash for HTTP::Request initializer API. ([@ixti]) * [#279](httprb/http#279) Send headers and body in one write if possible. This avoids a pathological case in Nagle's algorithm. ([@tarcieri]) * [#281](httprb/http#281) Remove legacy 'Http' constant alias to 'HTTP'. ([@tarcieri])
IO.select is an expensive call, because it has to build an fd_set (large bitfield) from an array each time we invoke it.
We're just interested in IO readiness, so on Ruby 2.0+ we can use the io/wait API instead, which adds wait_readable/wait_writable to IO objects.
cc @zanker @nerdrew