Skip to content

Commit

Permalink
fix write return error EAGAIN (#61)
Browse files Browse the repository at this point in the history
* fix unix.Write return EAGAIN
  • Loading branch information
Allenxuxu committed Mar 10, 2021
1 parent ca32d5c commit 3b17bb5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
11 changes: 4 additions & 7 deletions connection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import (
"strconv"
"time"

"github.com/Allenxuxu/gev/metrics"

"github.com/Allenxuxu/gev/eventloop"
"github.com/Allenxuxu/gev/log"
"github.com/Allenxuxu/gev/metrics"
"github.com/Allenxuxu/gev/poller"
"github.com/Allenxuxu/ringbuffer"
"github.com/Allenxuxu/ringbuffer/pool"
Expand Down Expand Up @@ -286,14 +285,12 @@ func (c *Connection) sendInLoop(data []byte) {
_, _ = c.outBuffer.Write(data)
} else {
n, err := unix.Write(c.fd, data)
if err != nil {
if err == unix.EAGAIN {
return
}
if err != nil && err != unix.EAGAIN {
c.handleClose(c.fd)
return
}
if n == 0 {

if n <= 0 {
_, _ = c.outBuffer.Write(data)
} else if n < len(data) {
_, _ = c.outBuffer.Write(data[n:])
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ require (
github.com/tidwall/evio v1.0.2
golang.org/x/net v0.0.0-20200625001655-4c5254603344
golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e
google.golang.org/protobuf v1.23.0
)

0 comments on commit 3b17bb5

Please sign in to comment.