Add conn health check

This commit is contained in:
Vladimir Mihailenco 2019-08-09 15:11:52 +03:00
parent 191391d66d
commit 4d3ed95bd9
2 changed files with 10 additions and 0 deletions

View File

@ -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

View File

@ -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)
}