Skip to content

Commit

Permalink
fix(client): keep ref to resp to avoid conn closed
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaost committed Nov 26, 2024
1 parent baa2cd2 commit 19e7961
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,6 @@ func (p *ClientUpgrader) UpgradeResponse(req *protocol.Request, resp *protocol.R
conn.newCompressionWriter = compressNoContextTakeover
conn.newDecompressionReader = decompressNoContextTakeover
}
conn.resp = resp
return conn, nil
}
4 changes: 4 additions & 0 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ type Conn struct {

readDecompress bool // whether last read frame had RSV1 set
newDecompressionReader func(io.Reader) io.ReadCloser

// keep reference to the resp to make sure the underyling conn will not be closed.
// see: https://github.com/cloudwego/hertz/pull/1214 for the details.
resp interface{} // *protocol.Response
}

func newConn(conn net.Conn, isServer bool, readBufferSize, writeBufferSize int, writeBufferPool BufferPool, br *bufio.Reader, writeBuf []byte) *Conn {
Expand Down

0 comments on commit 19e7961

Please sign in to comment.