Skip to content

Commit a5fce2a

Browse files
author
luominggang
committed
Flush response immediately to ensure in some circumstances the request can be proceed correctly
1 parent ed3793a commit a5fce2a

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

server.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,16 +1980,9 @@ func (s *Server) serveConn(c net.Conn) error {
19801980
break
19811981
}
19821982

1983-
// Only flush the writer if we don't have another request in the pipeline.
1984-
// This is a big of an ugly optimization for https://www.techempower.com/benchmarks/
1985-
// This benchmark will send 16 pipelined requests. It is faster to pack as many responses
1986-
// in a TCP packet and send it back at once than waiting for a flush every request.
1987-
// In real world circumstances this behaviour could be argued as being wrong.
1988-
if br == nil || br.Buffered() == 0 || connectionClose {
1989-
err = bw.Flush()
1990-
if err != nil {
1991-
break
1992-
}
1983+
err = bw.Flush()
1984+
if err != nil {
1985+
break
19931986
}
19941987
if connectionClose {
19951988
break

0 commit comments

Comments
 (0)