aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jille Timmermans <jille@quis.cx> 2023-12-02 18:04:12 +0100
committerGravatar GitHub <noreply@github.com> 2023-12-02 18:04:12 +0100
commit9b4e42affab59855632cdd7b1dcacca8a0ce83dd (patch)
treece7dd1517865e679c8a8e0f99520b2950696eea0
parentadd support for custom dial function with timeouts (#1669) (diff)
downloadfasthttp-9b4e42affab59855632cdd7b1dcacca8a0ce83dd.tar.gz
fasthttp-9b4e42affab59855632cdd7b1dcacca8a0ce83dd.tar.bz2
fasthttp-9b4e42affab59855632cdd7b1dcacca8a0ce83dd.zip
bug: Flush the write buffer before putting it to the pool (#1672)
A few lines later we check if `s.ReduceMemoryUsage && hijackHandler == nil` and call releaseWriter. We need to flush the buffer before returning it to the pool to avoid the data getting lost.
-rw-r--r--server.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/server.go b/server.go
index c981eb4..eaafe1c 100644
--- a/server.go
+++ b/server.go
@@ -2415,7 +2415,7 @@ func (s *Server) serveConn(c net.Conn) (err error) {
// This benchmark will send 16 pipelined requests. It is faster to pack as many responses
// in a TCP packet and send it back at once than waiting for a flush every request.
// In real world circumstances this behaviour could be argued as being wrong.
- if br == nil || br.Buffered() == 0 || connectionClose {
+ if br == nil || br.Buffered() == 0 || connectionClose || (s.ReduceMemoryUsage && hijackHandler == nil) {
err = bw.Flush()
if err != nil {
break