Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit81afa8a

Browse files
committed
netconn: Avoid returning 0, nil in NetConn.Read
Closes#367
1 parenta02cbef commit81afa8a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

‎netconn.go‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,19 @@ func (nc *netConn) Read(p []byte) (int, error) {
141141
nc.readMu.forceLock()
142142
defernc.readMu.unlock()
143143

144+
for {
145+
n,err:=nc.read(p)
146+
iferr!=nil {
147+
returnn,err
148+
}
149+
ifn==0 {
150+
continue
151+
}
152+
returnn,nil
153+
}
154+
}
155+
156+
func (nc*netConn)read(p []byte) (int,error) {
144157
ifatomic.LoadInt64(&nc.readExpired)==1 {
145158
return0,fmt.Errorf("failed to read: %w",context.DeadlineExceeded)
146159
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp