Skip to content

Commit 149e806

Browse files
author
unknown
committed
M
1 parent 4d2a3c2 commit 149e806

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

redis/asyncpool.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (p *AsyncPool) Get() AsynConn {
6666
}
6767

6868
p.getCount++
69-
if p.MaxGetCount != 0 && p.getCount >= p.MaxGetCount {
69+
if p.MaxGetCount != 0 && p.getCount > p.MaxGetCount {
7070
p.getCount--
7171
p.mu.Unlock()
7272
return errorConnection{ErrPoolExhausted}
@@ -187,17 +187,17 @@ func (pc *asyncPoolConnection) Err() error {
187187

188188
func (pc *asyncPoolConnection) Do(commandName string, args ...interface{}) (reply interface{}, err error) {
189189
if pc.p.MaxDoCount != 0 {
190-
if atomic.AddInt32(&pc.p.doCount, 1) >= int32(pc.p.MaxDoCount) {
190+
if atomic.AddInt32(&pc.p.doCount, 1) > int32(pc.p.MaxDoCount) {
191191
atomic.AddInt32(&pc.p.doCount, -1)
192192
return nil, ErrPoolExhausted
193193
}
194-
}
195194

196-
reply, err = pc.c.Do(commandName, args...)
197-
if pc.p.MaxDoCount != 0 {
198-
atomic.AddInt32(&pc.p.doCount, -1)
195+
defer func() {
196+
atomic.AddInt32(&pc.p.doCount, -1)
197+
}()
199198
}
200-
return reply, err
199+
200+
return pc.c.Do(commandName, args...)
201201
}
202202

203203
func (pc *asyncPoolConnection) AsyncDo(commandName string, args ...interface{}) (ret AsyncRet, err error) {

0 commit comments

Comments
 (0)