Skip to content

Commit

Permalink
fix: enqueue
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroyky committed Nov 17, 2023
1 parent 92e6f7a commit 4d5aeac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 7 additions & 5 deletions memcache/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,13 @@ func (p *pool) enqueueNewFreeConn() error {
createdAt: now,
}

p.freeconns <- newConn
p.lk.Lock()
defer p.lk.Unlock()
p.freeconnsNum++
p.openconnsNum++
go func() {
p.freeconns <- newConn
p.lk.Lock()
defer p.lk.Unlock()
p.freeconnsNum++
p.openconnsNum++
}()

return nil
}
Expand Down
4 changes: 3 additions & 1 deletion memcache/pool_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package memcache

import "testing"
import (
"testing"
)

func TestPool_isNewConnOk(t *testing.T) {
t.Run("MaxOpenConn is zero", func(t *testing.T) {
Expand Down

0 comments on commit 4d5aeac

Please sign in to comment.