Dont log errors if client closes connections.

This commit is contained in:
Sascha L. Teichmann 2014-08-04 15:18:32 +02:00
parent 7a98421645
commit 61cc35fda8
2 changed files with 5 additions and 1 deletions

View File

@ -39,6 +39,7 @@ func (c *Connection) Run() {
r := bufio.NewReader(c.conn) r := bufio.NewReader(c.conn)
parser := NewRedisParser(r, rce) parser := NewRedisParser(r, rce)
parser.Parse() parser.Parse()
log.Println("client disconnected")
} }
func logError(err error) { func logError(err error) {

View File

@ -8,6 +8,7 @@ import (
"bufio" "bufio"
"bytes" "bytes"
"fmt" "fmt"
"io"
"log" "log"
"strconv" "strconv"
) )
@ -39,7 +40,9 @@ func (rp *RedisParser) Parse() {
func (rp *RedisParser) nextLine() []byte { func (rp *RedisParser) nextLine() []byte {
line, err := rp.reader.ReadBytes('\n') line, err := rp.reader.ReadBytes('\n')
if err != nil { if err != nil {
rp.consumer.ConsumeError(err) if err != io.EOF {
rp.consumer.ConsumeError(err)
}
return nil return nil
} }
return bytes.TrimRight(line, "\r\n") return bytes.TrimRight(line, "\r\n")