forked from mirror/redis
Add conn health check
This commit is contained in:
parent
191391d66d
commit
4d3ed95bd9
|
@ -310,6 +310,12 @@ func (p *ConnPool) popIdle() *Conn {
|
|||
}
|
||||
|
||||
func (p *ConnPool) Put(cn *Conn) {
|
||||
if cn.rd.Buffered() > 0 {
|
||||
internal.Logger.Printf("Conn has unread data")
|
||||
p.Remove(cn, BadConnError{})
|
||||
return
|
||||
}
|
||||
|
||||
if !cn.pooled {
|
||||
p.Remove(cn, nil)
|
||||
return
|
||||
|
|
|
@ -41,6 +41,10 @@ func NewReader(rd io.Reader) *Reader {
|
|||
}
|
||||
}
|
||||
|
||||
func (r *Reader) Buffered() int {
|
||||
return r.rd.Buffered()
|
||||
}
|
||||
|
||||
func (r *Reader) Reset(rd io.Reader) {
|
||||
r.rd.Reset(rd)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue