]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[OPTIM] http: don't send each chunk in a separate packet
authorWilly Tarreau <w@1wt.eu>
Wed, 1 Dec 2010 23:37:14 +0000 (00:37 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 1 Dec 2010 23:39:33 +0000 (00:39 +0100)
When forwarding chunk-encoded data, each chunk gets a TCP PUSH flag when
going onto the wire simply because the send() function does not know that
some data remain after it (next chunk). Now we set the BF_EXPECT_MORE flag
on the buffer if the chunk size is not null. That way we can reduce the
number of packets sent, which is particularly noticeable when forwarding
compressed data, especially as it requires less ACKs from the client.

src/proto_http.c

index aa3ed531043a4fa3e70edbecd8b4be3d5edb61ff..4dcefca2da435d51bafef57919a4032df2db4083 100644 (file)
@@ -4364,6 +4364,9 @@ int http_request_forward_body(struct session *s, struct buffer *req, int an_bit)
                                goto return_bad_req;
                        }
                        /* otherwise we're in HTTP_MSG_DATA or HTTP_MSG_TRAILERS state */
+                       /* Don't set a PUSH at the end of that chunk if it's not the last one */
+                       if (msg->msg_state == HTTP_MSG_DATA)
+                               req->flags |= BF_EXPECT_MORE;
                }
                else if (msg->msg_state == HTTP_MSG_DATA_CRLF) {
                        /* we want the CRLF after the data */
@@ -5342,6 +5345,9 @@ int http_response_forward_body(struct session *s, struct buffer *res, int an_bit
                        else if (ret < 0)
                                goto return_bad_res;
                        /* otherwise we're in HTTP_MSG_DATA or HTTP_MSG_TRAILERS state */
+                       /* Don't set a PUSH at the end of that chunk if it's not the last one */
+                       if (msg->msg_state == HTTP_MSG_DATA)
+                               res->flags |= BF_EXPECT_MORE;
                }
                else if (msg->msg_state == HTTP_MSG_DATA_CRLF) {
                        /* we want the CRLF after the data */