Skip to content

Commit

Permalink
Handling of EOF errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
diiyw committed Jan 8, 2025
1 parent 44beaa6 commit a7bbed3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ func client(n *Nodis, conn *redis.Conn, cmd redis.Command) {
conn.WriteString("id=1 addr=" + conn.Network.RemoteAddr().String() + " fd=5 name= age=0 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=0 qbuf-free=0 obl=0 oll=0 omem=0 events=r cmd=client")
case "SETNAME":
conn.WriteString("OK")
case "SETINFO":
conn.WriteString("OK")
default:
conn.WriteError("CLIENT subcommand must be provided")
}
Expand Down
2 changes: 1 addition & 1 deletion redis/resp.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Reader struct {
cmd Command
}

const defaultSize = 4096
const defaultSize = 2048

func NewReader(rd io.Reader) *Reader {
return &Reader{
Expand Down
4 changes: 2 additions & 2 deletions redis/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ func handleConn(conn net.Conn, handler HandlerFunc) {
}
for {
err := c.Reader.ReadCommand()
if err != nil && err != io.EOF {
if _, ok := err.(*net.OpError); ok {
if err != nil {
if _, ok := err.(*net.OpError); ok || err == io.EOF {
c.Writer.Reset()
break
}
Expand Down

0 comments on commit a7bbed3

Please sign in to comment.