refine SetReadDeadline

This commit is contained in:
sunlei3 [孙雷] 2017-10-10 17:40:44 +08:00
parent c908dc801c
commit ad3825164f
1 changed files with 4 additions and 0 deletions

View File

@ -16,6 +16,7 @@ import (
"sync"
"time"
"unicode/utf8"
"strings"
)
const (
@ -1029,6 +1030,9 @@ func (c *Conn) ReadMessage() (messageType int, p []byte, err error) {
// all future reads will return an error. A zero value for t means reads will
// not time out.
func (c *Conn) SetReadDeadline(t time.Time) error {
if c.readErr != nil && strings.Contains(c.readErr.Error(), "i/o timeout") {
c.readErr = nil
}
return c.conn.SetReadDeadline(t)
}