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)
133
133
134
134
# Reads data from the underlying stream as efficiently as possible.
135
135
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?
138
137
result = @io . read_nonblock ( size , buffer , exception : false )
139
138
140
139
case result
@@ -146,8 +145,10 @@ def sysread(size, buffer)
146
145
return result
147
146
end
148
147
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"
151
152
end
152
153
end
153
154
end
Original file line number Diff line number Diff line change 3
3
## Unreleased
4
4
5
5
- 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.
6
7
7
8
## v0.7.0
8
9
You can’t perform that action at this time.
0 commit comments