Skip to content

Commit 3b17bb5

Browse files
authored
fix write return error EAGAIN (#61)
* fix unix.Write return EAGAIN
1 parent ca32d5c commit 3b17bb5

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

connection/connection.go

+4-7
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import (
77
"strconv"
88
"time"
99

10-
"github.com/Allenxuxu/gev/metrics"
11-
1210
"github.com/Allenxuxu/gev/eventloop"
1311
"github.com/Allenxuxu/gev/log"
12+
"github.com/Allenxuxu/gev/metrics"
1413
"github.com/Allenxuxu/gev/poller"
1514
"github.com/Allenxuxu/ringbuffer"
1615
"github.com/Allenxuxu/ringbuffer/pool"
@@ -286,14 +285,12 @@ func (c *Connection) sendInLoop(data []byte) {
286285
_, _ = c.outBuffer.Write(data)
287286
} else {
288287
n, err := unix.Write(c.fd, data)
289-
if err != nil {
290-
if err == unix.EAGAIN {
291-
return
292-
}
288+
if err != nil && err != unix.EAGAIN {
293289
c.handleClose(c.fd)
294290
return
295291
}
296-
if n == 0 {
292+
293+
if n <= 0 {
297294
_, _ = c.outBuffer.Write(data)
298295
} else if n < len(data) {
299296
_, _ = c.outBuffer.Write(data[n:])

go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ require (
1616
github.com/tidwall/evio v1.0.2
1717
golang.org/x/net v0.0.0-20200625001655-4c5254603344
1818
golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e
19+
google.golang.org/protobuf v1.23.0
1920
)

0 commit comments

Comments
 (0)