Skip to content

@headius /gist:6477733
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Start to remove the extra buffering in openssl/buffering.rb
diff --git a/lib/ruby/1.9/openssl/buffering.rb b/lib/ruby/1.9/openssl/buffering.rb
index 51bc968..f07a55f 100644
--- a/lib/ruby/1.9/openssl/buffering.rb
+++ b/lib/ruby/1.9/openssl/buffering.rb
@@ -81,24 +81,7 @@ module OpenSSL::Buffering
# See IO#read for full details.
def read(size=nil, buf=nil)
- if size == 0
- if buf
- buf.clear
- return buf
- else
- return ""
- end
- end
- until @eof
- break if size && size <= @rbuffer.size
- fill_rbuff
- end
- ret = consume_rbuff(size) || ""
- if buf
- buf.replace(ret)
- ret = buf
- end
- (size && ret.empty?) ? nil : ret
+ sysread(size, buf)
end
##
@@ -108,28 +91,11 @@ module OpenSSL::Buffering
# See IO#readpartial for full details.
def readpartial(maxlen, buf=nil)
- if maxlen == 0
- if buf
- buf.clear
- return buf
- else
- return ""
- end
- end
- if @rbuffer.empty?
- begin
- return sysread(maxlen, buf)
- rescue Errno::EAGAIN
- retry
- end
- end
- ret = consume_rbuff(maxlen)
- if buf
- buf.replace(ret)
- ret = buf
+ begin
+ return sysread(maxlen, buf)
+ rescue Errno::EAGAIN
+ retry
end
- raise EOFError if ret.empty?
- ret
end
##
@@ -162,24 +128,7 @@ module OpenSSL::Buffering
# more details. http://www.openssl.org/support/faq.html
def read_nonblock(maxlen, buf=nil)
- if maxlen == 0
- if buf
- buf.clear
- return buf
- else
- return ""
- end
- end
- if @rbuffer.empty?
- return sysread_nonblock(maxlen, buf)
- end
- ret = consume_rbuff(maxlen)
- if buf
- buf.replace(ret)
- ret = buf
- end
- raise EOFError if ret.empty?
- ret
+ sysread_nonblock(maxlen, buf)
end
##
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.