From deb14cfd901a252aa2ac0395db8d5c553d271248 Mon Sep 17 00:00:00 2001 From: Anmol Sethi <hi@nhooyr.io> Date: Thu, 27 Feb 2020 16:09:06 -0500 Subject: [PATCH] Make sure to release lock when acquiring and connection is closed. Closes #205 --- conn_notjs.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/conn_notjs.go b/conn_notjs.go index 2ec5f5b..bb2eb22 100644 --- a/conn_notjs.go +++ b/conn_notjs.go @@ -245,9 +245,11 @@ func (m *mu) lock(ctx context.Context) error { case m.ch <- struct{}{}: // To make sure the connection is certainly alive. // As it's possible the send on m.ch was selected - // the receive on closed. + // over the receive on closed. select { case <-m.c.closed: + // Make sure to release. + m.unlock() return m.c.closeErr default: } -- GitLab