]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
Revert "MEDIUM: proto_htx: Switch to infinite forwarding if there is no data filter"
authorWilly Tarreau <w@1wt.eu>
Thu, 21 Mar 2019 17:00:30 +0000 (18:00 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 21 Mar 2019 17:28:31 +0000 (18:28 +0100)
This reverts commit f52170d2f47efbace729bc88349eb189968df568.

This commit was merged too early, some areas are not ready and
transfers from H1 to H2 often stall. Christopher suggested to wait
for the other parts to be ready before reintroducing it.

src/proto_htx.c

index 80d7fa15c38d8ea4d583abc87d6d297c38b7db09..bdfd4ba71e4fde15369e4511b5afc12a24b6cd17 100644 (file)
@@ -1212,18 +1212,9 @@ int htx_request_forward_body(struct stream *s, struct channel *req, int an_bit)
        channel_auto_close(req);
 
        if (req->to_forward) {
-               if (req->to_forward == CHN_INFINITE_FORWARD) {
-                       if (req->flags & CF_SHUTR) {
-                               msg->msg_state = HTTP_MSG_DONE;
-                               req->to_forward = 0;
-                               goto done;
-                       }
-               }
-               else {
-                       /* We can't process the buffer's contents yet */
-                       req->flags |= CF_WAKE_WRITE;
-                       goto missing_data_or_waiting;
-               }
+               /* We can't process the buffer's contents yet */
+               req->flags |= CF_WAKE_WRITE;
+               goto missing_data_or_waiting;
        }
 
        if (msg->msg_state >= HTTP_MSG_DONE)
@@ -1242,8 +1233,14 @@ int htx_request_forward_body(struct stream *s, struct channel *req, int an_bit)
        }
        else {
                c_adv(req, htx->data - co_data(req));
-               if (msg->flags & HTTP_MSGF_XFER_LEN)
-                       channel_htx_forward_forever(req, htx);
+
+               /* To let the function channel_forward work as expected we must update
+                * the channel's buffer to pretend there is no more input data. The
+                * right length is then restored. We must do that, because when an HTX
+                * message is stored into a buffer, it appears as full.
+                */
+               if ((msg->flags & HTTP_MSGF_XFER_LEN) && htx->extra)
+                       htx->extra -= channel_htx_forward(req, htx, htx->extra);
        }
 
        /* Check if the end-of-message is reached and if so, switch the message
@@ -1253,7 +1250,6 @@ int htx_request_forward_body(struct stream *s, struct channel *req, int an_bit)
                goto missing_data_or_waiting;
 
        msg->msg_state = HTTP_MSG_DONE;
-       req->to_forward = 0;
 
   done:
        /* other states, DONE...TUNNEL */
@@ -2134,18 +2130,9 @@ int htx_response_forward_body(struct stream *s, struct channel *res, int an_bit)
        channel_auto_close(res);
 
        if (res->to_forward) {
-               if (res->to_forward == CHN_INFINITE_FORWARD) {
-                       if (res->flags & CF_SHUTR) {
-                               msg->msg_state = HTTP_MSG_DONE;
-                               res->to_forward = 0;
-                               goto done;
-                       }
-               }
-               else {
-                       /* We can't process the buffer's contents yet */
-                       res->flags |= CF_WAKE_WRITE;
-                       goto missing_data_or_waiting;
-               }
+                /* We can't process the buffer's contents yet */
+               res->flags |= CF_WAKE_WRITE;
+               goto missing_data_or_waiting;
        }
 
        if (msg->msg_state >= HTTP_MSG_DONE)
@@ -2165,8 +2152,14 @@ int htx_response_forward_body(struct stream *s, struct channel *res, int an_bit)
        }
        else {
                c_adv(res, htx->data - co_data(res));
-               if (msg->flags & HTTP_MSGF_XFER_LEN)
-                       channel_htx_forward_forever(res, htx);
+
+               /* To let the function channel_forward work as expected we must update
+                * the channel's buffer to pretend there is no more input data. The
+                * right length is then restored. We must do that, because when an HTX
+                * message is stored into a buffer, it appears as full.
+                */
+               if ((msg->flags & HTTP_MSGF_XFER_LEN) && htx->extra)
+                       htx->extra -= channel_htx_forward(res, htx, htx->extra);
        }
 
        if (!(msg->flags & HTTP_MSGF_XFER_LEN)) {
@@ -2184,7 +2177,6 @@ int htx_response_forward_body(struct stream *s, struct channel *res, int an_bit)
                goto missing_data_or_waiting;
 
        msg->msg_state = HTTP_MSG_DONE;
-       res->to_forward = 0;
 
   done:
        /* other states, DONE...TUNNEL */