Skip to content

Commit

Permalink
bug: return 0 instead of -1 when error occurred on a write
Browse files Browse the repository at this point in the history
  • Loading branch information
daynobug committed Apr 5, 2024
1 parent f5e5ef9 commit cb1207e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions connection_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func (c *conn) write(data []byte) (n int, err error) {
logging.Errorf("failed to close connection(fd=%d,peer=%+v) on conn.write: %v",
c.fd, c.remoteAddr, err)
}
return -1, os.NewSyscallError("write", err)
return 0, os.NewSyscallError("write", err)

Check warning on line 152 in connection_unix.go

View check run for this annotation

Codecov / codecov/patch

connection_unix.go#L152

Added line #L152 was not covered by tests
}
// Failed to send all data back to the peer, buffer the leftover data for the next round.
if sent < n {
Expand Down Expand Up @@ -183,7 +183,7 @@ func (c *conn) writev(bs [][]byte) (n int, err error) {
logging.Errorf("failed to close connection(fd=%d,peer=%+v) on conn.writev: %v",
c.fd, c.remoteAddr, err)
}
return -1, os.NewSyscallError("writev", err)
return 0, os.NewSyscallError("writev", err)

Check warning on line 186 in connection_unix.go

View check run for this annotation

Codecov / codecov/patch

connection_unix.go#L186

Added line #L186 was not covered by tests
}
// Failed to send all data back to the peer, buffer the leftover data for the next round.
if sent < n {
Expand Down

0 comments on commit cb1207e

Please sign in to comment.