From dca3a3b5535c5752bd2507501d07737b2403b4c8 Mon Sep 17 00:00:00 2001 From: Ak-Army Date: Thu, 24 Feb 2022 10:32:09 +0100 Subject: [PATCH] [fix] http transport deadlock (#2441) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Hunyadvári Péter --- transport/http_transport.go | 1 + transport/http_transport_test.go | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/transport/http_transport.go b/transport/http_transport.go index ed311eb4..f41c25ce 100644 --- a/transport/http_transport.go +++ b/transport/http_transport.go @@ -141,6 +141,7 @@ func (h *httpTransportClient) Recv(m *Message) error { h.Lock() if h.closed { + h.Unlock() return io.EOF } rsp, err := http.ReadResponse(h.buff, r) diff --git a/transport/http_transport_test.go b/transport/http_transport_test.go index eb922167..b08073ef 100644 --- a/transport/http_transport_test.go +++ b/transport/http_transport_test.go @@ -1,7 +1,6 @@ package transport import ( - "fmt" "io" "net" "sync" @@ -303,11 +302,11 @@ func TestHTTPTransportCloseWhenRecv(t *testing.T) { if err := c.Recv(&rm); err != nil { if err == io.EOF { + c.Recv(&rm) return } t.Errorf("Unexpected recv err: %v", err) } - fmt.Println("aa") } }() for i := 1; i < 3; i++ {