Skip to content

fix write return error EAGAIN #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
)