From a20c8908de674d5c35ea3f0877ae798a7a9b8a92 Mon Sep 17 00:00:00 2001 From: Sam Fredrickson Date: Mon, 10 Jul 2023 10:55:25 -0700 Subject: [PATCH] Unlock() before panic() when already closed. --- mq/lib.go | 1 + npq/lib.go | 1 + pq/lib.go | 1 + 3 files changed, 3 insertions(+) diff --git a/mq/lib.go b/mq/lib.go index 4686a21..f93bda3 100644 --- a/mq/lib.go +++ b/mq/lib.go @@ -73,6 +73,7 @@ type state[T any] struct { func (s *state[T]) Close() { s.mu.Lock() if s.closed { + s.mu.Unlock() panic("close of closed queue") } s.closed = true diff --git a/npq/lib.go b/npq/lib.go index 6496397..2e0d79f 100644 --- a/npq/lib.go +++ b/npq/lib.go @@ -93,6 +93,7 @@ type state[P constraints.Integer, T any] struct { func (s *state[P, T]) Close() { s.mu.Lock() if s.closed { + s.mu.Unlock() panic("close of closed queue") } s.closed = true diff --git a/pq/lib.go b/pq/lib.go index d69dcf5..8f45a8f 100644 --- a/pq/lib.go +++ b/pq/lib.go @@ -61,6 +61,7 @@ type state[P constraints.Ordered, T any] struct { func (s *state[P, T]) Close() { s.mu.Lock() if s.closed { + s.mu.Unlock() panic("close of closed queue") } s.closed = true