From 48ba9f91b46a468353b2053745eec2a9d6ee1708 Mon Sep 17 00:00:00 2001 From: Ak-Army Date: Fri, 22 Jul 2022 09:36:36 +0200 Subject: [PATCH] Fix panic in httpTransportClient.Recv (#2530) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [fix] http transport can send when wait for recv * [fix] http transport can send multiple message and recevie them. Do not block send and receive on stream mode * [fix] http transport can close the connection when recv is in progress, add tests * [fix] Read buff before reset it, when the connection is closed Co-authored-by: Hunyadvári Péter --- transport/http_transport.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/transport/http_transport.go b/transport/http_transport.go index 1c454f90..7cb8d3c9 100644 --- a/transport/http_transport.go +++ b/transport/http_transport.go @@ -159,13 +159,14 @@ func (h *httpTransportClient) Recv(m *Message) error { return io.EOF } rsp, err := http.ReadResponse(h.buff, r) - h.Unlock() if err != nil { + h.Unlock() return err } defer rsp.Body.Close() b, err := ioutil.ReadAll(rsp.Body) + h.Unlock() if err != nil { return err }