forked from mirror/ledisdb
update godep, try to fix race test error
This commit is contained in:
parent
0e2f2569a0
commit
9f4693ef70
|
@ -60,7 +60,7 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "github.com/siddontang/goredis",
|
||||
"Rev": "41bbdaa8d2015389bfa495ee4e7ee4d150376751"
|
||||
"Rev": "f711beb9ecead18cf638a898610aa2c24ccb6dc7"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/siddontang/rdb",
|
||||
|
|
|
@ -13,7 +13,7 @@ type PoolConn struct {
|
|||
}
|
||||
|
||||
func (c *PoolConn) Close() {
|
||||
if c.Conn.closed {
|
||||
if c.Conn.isClosed() {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"io"
|
||||
"net"
|
||||
"strconv"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -38,7 +39,7 @@ type Conn struct {
|
|||
totalReadSize sizeWriter
|
||||
totalWriteSize sizeWriter
|
||||
|
||||
closed bool
|
||||
closed int32
|
||||
}
|
||||
|
||||
func Connect(addr string) (*Conn, error) {
|
||||
|
@ -57,18 +58,23 @@ func ConnectWithSize(addr string, readSize int, writeSize int) (*Conn, error) {
|
|||
c.br = bufio.NewReaderSize(io.TeeReader(c.c, &c.totalReadSize), readSize)
|
||||
c.bw = bufio.NewWriterSize(io.MultiWriter(c.c, &c.totalWriteSize), writeSize)
|
||||
|
||||
c.closed = false
|
||||
atomic.StoreInt32(&c.closed, 0)
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func (c *Conn) Close() {
|
||||
if c.closed {
|
||||
if atomic.LoadInt32(&c.closed) == 1 {
|
||||
return
|
||||
}
|
||||
|
||||
c.c.Close()
|
||||
c.closed = true
|
||||
|
||||
atomic.StoreInt32(&c.closed, 1)
|
||||
}
|
||||
|
||||
func (c *Conn) isClosed() bool {
|
||||
return atomic.LoadInt32(&c.closed) == 1
|
||||
}
|
||||
|
||||
func (c *Conn) GetTotalReadSize() int64 {
|
||||
|
|
Loading…
Reference in New Issue