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 064241e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 8 additions & 1 deletion memcache/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@ func (p *pool) enqueueNewFreeConn() error {
createdAt: now,
}

p.freeconns <- newConn
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
p.freeconns <- newConn
}()
wg.Wait()

p.lk.Lock()
defer p.lk.Unlock()
p.freeconnsNum++
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 064241e

Please sign in to comment.