Skip to content

Commit a2605e7

Browse files
committed
Fix PubSub.Ping to hold the lock
1 parent 917c476 commit a2605e7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pubsub.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,13 +252,16 @@ func (c *PubSub) Ping(ctx context.Context, payload ...string) error {
252252
}
253253
cmd := NewCmd(ctx, args...)
254254

255-
cn, err := c.connWithLock(ctx)
255+
c.mu.Lock()
256+
defer c.mu.Unlock()
257+
258+
cn, err := c.conn(ctx, nil)
256259
if err != nil {
257260
return err
258261
}
259262

260263
err = c.writeCmd(ctx, cn, cmd)
261-
c.releaseConnWithLock(ctx, cn, err, false)
264+
c.releaseConn(ctx, cn, err, false)
262265
return err
263266
}
264267

0 commit comments

Comments
 (0)