From bdc7867793849086709cbb7fe65e51661da00eb5 Mon Sep 17 00:00:00 2001 From: Kazuki Yamaguchi Date: Wed, 14 Oct 2026 00:23:23 +0900 Subject: [PATCH] ssl: do not rescue Errno::EAGAIN SSLSocket#sysread and #syswrite never raise Errno::EAGAIN. It appears to me that commit ruby/ruby@a9fb0817a154 (should wait for that the underlying IO become readable or writable if the error was SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE, 2005-03-05) made this rescue unnecessary. --- lib/openssl/buffering.rb | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/lib/openssl/buffering.rb b/lib/openssl/buffering.rb index 1464a4292..771cfc95c 100644 --- a/lib/openssl/buffering.rb +++ b/lib/openssl/buffering.rb @@ -74,8 +74,6 @@ def initialize(*) def fill_rbuff begin @rbuffer.append_as_bytes(self.sysread(BLOCK_SIZE)) - rescue Errno::EAGAIN - retry rescue EOFError @eof = true end @@ -152,11 +150,7 @@ def readpartial(maxlen, buf=nil) end end if @rbuffer.empty? - begin - return sysread(maxlen, buf) - rescue Errno::EAGAIN - retry - end + return sysread(maxlen, buf) end ret = consume_rbuff(maxlen) if buf @@ -356,17 +350,13 @@ def do_write(s) nwrote = 0 begin while nwrote < buffer_size do - begin - chunk = if nwrote > 0 - @wbuffer.byteslice(nwrote, @wbuffer.bytesize) - else - @wbuffer - end - - nwrote += syswrite(chunk) - rescue Errno::EAGAIN - retry + chunk = if nwrote > 0 + @wbuffer.byteslice(nwrote, @wbuffer.bytesize) + else + @wbuffer end + + nwrote += syswrite(chunk) end ensure if nwrote < @wbuffer.bytesize