File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff 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
@@ -361,6 +364,8 @@ func (c *PubSub) ReceiveTimeout(ctx context.Context, timeout time.Duration) (int
361364 c .cmd = NewCmd (ctx )
362365 }
363366
367+ // Don't hold the lock to allow subscriptions and pings.
368+
364369 cn , err := c .connWithLock (ctx )
365370 if err != nil {
366371 return nil , err
@@ -371,6 +376,7 @@ func (c *PubSub) ReceiveTimeout(ctx context.Context, timeout time.Duration) (int
371376 })
372377
373378 c .releaseConnWithLock (ctx , cn , err , timeout > 0 )
379+
374380 if err != nil {
375381 return nil , err
376382 }
You can’t perform that action at this time.
0 commit comments