Skip to content

Commit

Permalink
chore: fix bad mutex usage
Browse files Browse the repository at this point in the history
  • Loading branch information
endigma committed Feb 12, 2025
1 parent 837e1b1 commit c218ba6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions router-tests/testenv/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,19 @@ func setupKafkaServer(t testing.TB) (*KafkaData, error) {
kafkaRefs += 1

t.Cleanup(func() {
t.Log("cleaning up kafka")
kafkaMux.Lock()
defer kafkaMux.Unlock()

if kafkaRefs > 1 {
kafkaRefs -= 1
} else {
if err := kafkaContainer.Close(); err != nil {
t.Fatalf("could not purge kafka container: %s", err.Error())
}
kafkaMux.Lock()
// This shouldn't be needed, but just in case
kafkaData = nil
kafkaContainer = nil
kafkaRefs = 0
kafkaMux.Unlock()
}
})

Expand Down

0 comments on commit c218ba6

Please sign in to comment.