]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MEDIUM] http: make the parsers able to wait for a buffer flush
authorWilly Tarreau <w@1wt.eu>
Sat, 2 Jan 2010 21:04:45 +0000 (22:04 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 2 Jan 2010 21:04:45 +0000 (22:04 +0100)
When too large a message lies in a buffer before parsing a new
request/response, we can now wait for previous outgoing data to
leave the buffer before attempting to parse again. After that
we can consider the opportunity to realign the buffer if needed.

src/proto_http.c

index 4d5d8e8ced183e54fc752a4cea4af6e8c6e998ca..5eec4b6c2d32ddf51d0741ff457f92b0f5af409f 100644 (file)
@@ -2106,21 +2106,24 @@ int http_wait_for_request(struct session *s, struct buffer *req, int an_bit)
         * protected area is affected, because we may have to move processed
         * data later, which is much more complicated.
         */
-       if (req->l &&
-           (req->r <= req->lr || req->r > req->data + req->size - global.tune.maxrewrite)) {
-               if (req->send_max) {
-                       /* some data has still not left the buffer, wake us once that's done */
-                       buffer_dont_connect(req);
-                       req->flags |= BF_READ_DONTWAIT; /* try to get back here ASAP */
-                       return 0;
+       if (req->l && msg->msg_state < HTTP_MSG_ERROR) {
+               if (unlikely((req->flags & BF_FULL) ||
+                            req->r < req->lr ||
+                            req->r > req->data + req->size - global.tune.maxrewrite)) {
+                       if (req->send_max) {
+                               /* some data has still not left the buffer, wake us once that's done */
+                               buffer_dont_connect(req);
+                               req->flags |= BF_READ_DONTWAIT; /* try to get back here ASAP */
+                               return 0;
+                       }
+                       if (req->l <= req->size - global.tune.maxrewrite)
+                               http_buffer_heavy_realign(req, msg);
                }
 
-               http_buffer_heavy_realign(req, msg);
+               if (likely(req->lr < req->r))
+                       http_msg_analyzer(req, msg, &txn->hdr_idx);
        }
 
-       if (likely(req->lr < req->r))
-               http_msg_analyzer(req, msg, &txn->hdr_idx);
-
        /* 1: we might have to print this header in debug mode */
        if (unlikely((global.mode & MODE_DEBUG) &&
                     (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)) &&
@@ -3456,20 +3459,24 @@ int http_wait_for_response(struct session *s, struct buffer *rep, int an_bit)
         * protected area is affected, because we may have to move processed
         * data later, which is much more complicated.
         */
-       if (rep->l &&
-           (rep->r <= rep->lr || rep->r > rep->data + rep->size - global.tune.maxrewrite)) {
-               if (rep->send_max) {
-                       /* some data has still not left the buffer, wake us once that's done */
-                       buffer_dont_close(rep);
-                       return 0;
+       if (rep->l && msg->msg_state < HTTP_MSG_ERROR) {
+               if (unlikely((rep->flags & BF_FULL) ||
+                            rep->r < rep->lr ||
+                            rep->r > rep->data + rep->size - global.tune.maxrewrite)) {
+                       if (rep->send_max) {
+                               /* some data has still not left the buffer, wake us once that's done */
+                               buffer_dont_close(rep);
+                               rep->flags |= BF_READ_DONTWAIT; /* try to get back here ASAP */
+                               return 0;
+                       }
+                       if (rep->l <= rep->size - global.tune.maxrewrite)
+                               http_buffer_heavy_realign(rep, msg);
                }
 
-               http_buffer_heavy_realign(rep, msg);
+               if (likely(rep->lr < rep->r))
+                       http_msg_analyzer(rep, msg, &txn->hdr_idx);
        }
 
-       if (likely(rep->lr < rep->r))
-               http_msg_analyzer(rep, msg, &txn->hdr_idx);
-
        /* 1: we might have to print this header in debug mode */
        if (unlikely((global.mode & MODE_DEBUG) &&
                     (!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)) &&