We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a02cbef commit c26a23dCopy full SHA for c26a23d
netconn.go
@@ -141,6 +141,10 @@ func (nc *netConn) Read(p []byte) (int, error) {
141
nc.readMu.forceLock()
142
defer nc.readMu.unlock()
143
144
+ return nc.read(p)
145
+}
146
+
147
+func (nc *netConn) read(p []byte) (int, error) {
148
if atomic.LoadInt64(&nc.readExpired) == 1 {
149
return 0, fmt.Errorf("failed to read: %w", context.DeadlineExceeded)
150
}
@@ -171,6 +175,10 @@ func (nc *netConn) Read(p []byte) (int, error) {
171
175
if err == io.EOF {
172
176
nc.reader = nil
173
177
err = nil
178
+ if n == 0 {
179
+ // Avoid returning 0, nil. #367
180
+ n, err = nc.read(p)
181
+ }
174
182
183
return n, err
184
0 commit comments