From 549d06bc984643555a0831e815a4e357593f1940 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Wed, 7 Apr 2021 08:33:19 -0400 Subject: [PATCH] simplify semaphore release code --- irc/utils/semaphores.go | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/irc/utils/semaphores.go b/irc/utils/semaphores.go index 2268cde7..431baee6 100644 --- a/irc/utils/semaphores.go +++ b/irc/utils/semaphores.go @@ -5,8 +5,6 @@ package utils import ( "context" - "log" - "runtime/debug" "time" ) @@ -67,15 +65,7 @@ func (semaphore *Semaphore) AcquireWithContext(ctx context.Context) (acquired bo return } -// Release releases a semaphore. It never blocks. (This is not a license -// to program spurious releases.) +// Release releases a semaphore. func (semaphore *Semaphore) Release() { - select { - case <-(*semaphore): - // good - default: - // spurious release - log.Printf("spurious semaphore release (full to capacity %d)", cap(*semaphore)) - debug.PrintStack() - } + <-(*semaphore) }