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",
|
"ImportPath": "github.com/siddontang/goredis",
|
||||||
"Rev": "41bbdaa8d2015389bfa495ee4e7ee4d150376751"
|
"Rev": "f711beb9ecead18cf638a898610aa2c24ccb6dc7"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/siddontang/rdb",
|
"ImportPath": "github.com/siddontang/rdb",
|
||||||
|
|
|
@ -13,7 +13,7 @@ type PoolConn struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *PoolConn) Close() {
|
func (c *PoolConn) Close() {
|
||||||
if c.Conn.closed {
|
if c.Conn.isClosed() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -38,7 +39,7 @@ type Conn struct {
|
||||||
totalReadSize sizeWriter
|
totalReadSize sizeWriter
|
||||||
totalWriteSize sizeWriter
|
totalWriteSize sizeWriter
|
||||||
|
|
||||||
closed bool
|
closed int32
|
||||||
}
|
}
|
||||||
|
|
||||||
func Connect(addr string) (*Conn, error) {
|
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.br = bufio.NewReaderSize(io.TeeReader(c.c, &c.totalReadSize), readSize)
|
||||||
c.bw = bufio.NewWriterSize(io.MultiWriter(c.c, &c.totalWriteSize), writeSize)
|
c.bw = bufio.NewWriterSize(io.MultiWriter(c.c, &c.totalWriteSize), writeSize)
|
||||||
|
|
||||||
c.closed = false
|
atomic.StoreInt32(&c.closed, 0)
|
||||||
|
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Conn) Close() {
|
func (c *Conn) Close() {
|
||||||
if c.closed {
|
if atomic.LoadInt32(&c.closed) == 1 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.c.Close()
|
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 {
|
func (c *Conn) GetTotalReadSize() int64 {
|
||||||
|
|
Loading…
Reference in New Issue