File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -133,8 +133,7 @@ def syswrite(buffer)
133133
134134 # Reads data from the underlying stream as efficiently as possible.
135135 def sysread ( size , buffer )
136- # Come on Ruby, why couldn't this just return `nil`? EOF is not exceptional. Every file has one.
137- while true
136+ while !@io . closed?
138137 result = @io . read_nonblock ( size , buffer , exception : false )
139138
140139 case result
@@ -146,8 +145,10 @@ def sysread(size, buffer)
146145 return result
147146 end
148147 end
149- rescue Errno ::EBADF
150- raise ::IOError , "stream closed"
148+
149+ # Otherwise, the `@io` was closed while reading:
150+ # https://github.com/ruby/openssl/issues/798
151+ raise ::IOError , "closed stream"
151152 end
152153 end
153154end
Original file line number Diff line number Diff line change 33## Unreleased
44
55 - On Ruby v3.3+, use ` IO#write ` directly instead of ` IO#write_nonblock ` , for better performance.
6+ - ` Buffered#sysread ` now checks ` @io.closed? ` before attempting to read, improving error handling.
67
78## v0.7.0
89
You can’t perform that action at this time.
0 commit comments