From fe2e33a4f2f28b6fda24fa924b2c89c23655b962 Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Mon, 4 Nov 2013 09:53:48 +0200 Subject: [PATCH] Simplify close. --- v2/pool.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/v2/pool.go b/v2/pool.go index a4c7df19..d87cd055 100644 --- a/v2/pool.go +++ b/v2/pool.go @@ -31,7 +31,7 @@ func newConn(netcn net.Conn) *conn { cn := &conn{ cn: netcn, } - cn.rd = bufio.NewReaderSize(cn, 1024) + cn.rd = bufio.NewReader(cn) return cn } @@ -53,6 +53,10 @@ func (cn *conn) Write(b []byte) (int, error) { return cn.cn.Write(b) } +func (cn *conn) Close() error { + return cn.cn.Close() +} + //------------------------------------------------------------------------------ type connPool struct { @@ -129,7 +133,7 @@ func (p *connPool) Put(cn *conn) error { func (p *connPool) Remove(cn *conn) error { var err error if cn != nil { - err = p.closeConn(cn) + err = cn.Close() } p.cond.L.Lock() p.size-- @@ -155,7 +159,7 @@ func (p *connPool) Close() error { p.cond.L.Lock() for e := p.conns.Front(); e != nil; e = e.Next() { - if err := p.closeConn(e.Value.(*conn)); err != nil { + if err := e.Value.(*conn).Close(); err != nil { return err } } @@ -165,10 +169,6 @@ func (p *connPool) Close() error { return nil } -func (p *connPool) closeConn(cn *conn) error { - return cn.cn.Close() -} - //------------------------------------------------------------------------------ type singleConnPool struct {