good morning!!!!

Skip to content
Snippets Groups Projects
Unverified Commit 81afa8a3 authored by Anmol Sethi's avatar Anmol Sethi
Browse files

netconn: Avoid returning 0, nil in NetConn.Read

Closes #367
parent a02cbef5
No related branches found
No related tags found
No related merge requests found
......@@ -141,6 +141,19 @@ func (nc *netConn) Read(p []byte) (int, error) {
nc.readMu.forceLock()
defer nc.readMu.unlock()
for {
n, err := nc.read(p)
if err != nil {
return n, err
}
if n == 0 {
continue
}
return n, nil
}
}
func (nc *netConn) read(p []byte) (int, error) {
if atomic.LoadInt64(&nc.readExpired) == 1 {
return 0, fmt.Errorf("failed to read: %w", context.DeadlineExceeded)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment