Skip to content

Commit

Permalink
fix blocking recv call on httpTransportClient
Browse files Browse the repository at this point in the history
  • Loading branch information
mapogolions committed Dec 29, 2024
1 parent 2529793 commit 9ee16e2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion transport/http_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,15 @@ func (h *httpTransportClient) Recv(msg *Message) (err error) {
var req *http.Request

if !h.dialOpts.Stream {
rc, ok := <-h.req

var rc *http.Request
var ok bool

select {
case rc, ok = <-h.req:
default:
}

if !ok {
h.Lock()
if len(h.reqList) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion transport/http_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/pkg/errors"
)

func TestHttpClientTransport(t *testing.T) {
func TestDefaultHttpClientTransport(t *testing.T) {
// arrange
l, c, err := echoHttpClient("127.0.0.1:")
if err != nil {
Expand Down

0 comments on commit 9ee16e2

Please sign in to comment.