Skip to content

Commit

Permalink
kfake: do not return early when running control functions if the clus…
Browse files Browse the repository at this point in the history
…ter is closed

If we return while running a control function (which is expected to be
fast), we may unlock a mutex that is currently unlocked and only
relocked after the control function exits.

Notably, tryControl was panicking because a cluster was closed while a
control function was running.
  • Loading branch information
twmb committed Jan 14, 2024
1 parent c69fa0b commit d9c8468
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions pkg/kfake/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,6 @@ outer:
inner:
for {
select {
case <-c.die:
return
case admin := <-c.adminCh:
admin()
continue inner
Expand Down Expand Up @@ -604,8 +602,6 @@ func (c *Cluster) tryControlKey(key int16, creq *clientReq) (kmsg.Response, erro
res := c.runControl(cctx, creq)
for {
select {
case <-c.die:
return nil, nil, false
case admin := <-c.adminCh:
admin()
continue
Expand Down

0 comments on commit d9c8468

Please sign in to comment.