public
Last active

Start to remove the extra buffering in openssl/buffering.rb

  • Download Gist
gistfile1.diff
Diff
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
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
##

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.