]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] http: take care of errors, timeouts and aborts during the data phase
authorWilly Tarreau <w@1wt.eu>
Sun, 3 Jan 2010 16:07:49 +0000 (17:07 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 3 Jan 2010 16:07:49 +0000 (17:07 +0100)
In server-close mode particularly, the response buffer is marked for
no-auto-close after a response passed through. This prevented a POST
request from being aborted on errors, timeouts or anything if the
response was received before the request was complete.

src/proto_http.c

index 1648083d4eb32ae8ed34a511329155a206c03663..2cab1989d64044bbc417a26ffdce703889531d40 100644 (file)
@@ -3256,7 +3256,10 @@ int http_request_forward_body(struct session *s, struct buffer *req, int an_bit)
        struct http_txn *txn = &s->txn;
        struct http_msg *msg = &s->txn.req;
 
-       if (req->flags & (BF_WRITE_ERROR|BF_WRITE_TIMEOUT)) {
+       if ((req->flags & (BF_READ_ERROR|BF_READ_TIMEOUT|BF_WRITE_ERROR|BF_WRITE_TIMEOUT)) ||
+           ((req->flags & BF_SHUTW) && (req->to_forward || req->send_max))) {
+               /* Output closed while we were sending data. We must abort. */
+               buffer_ignore(req, req->l - req->send_max);
                req->analysers &= ~an_bit;
                return 1;
        }
@@ -4368,7 +4371,11 @@ int http_response_forward_body(struct session *s, struct buffer *res, int an_bit
        struct http_txn *txn = &s->txn;
        struct http_msg *msg = &s->txn.rsp;
 
-       if (res->flags & (BF_WRITE_ERROR|BF_WRITE_TIMEOUT)) {
+       if ((res->flags & (BF_READ_ERROR|BF_READ_TIMEOUT|BF_WRITE_ERROR|BF_WRITE_TIMEOUT)) ||
+           !s->req->analysers) {
+               /* in case of error or if the other analyser went away, we can't analyse HTTP anymore */
+               buffer_ignore(res, res->l - res->send_max);
+               buffer_auto_close(res);
                res->analysers &= ~an_bit;
                return 1;
        }
@@ -4515,6 +4522,8 @@ int http_response_forward_body(struct session *s, struct buffer *res, int an_bit
                }
        }
 
+       buffer_ignore(res, res->l - res->send_max);
+       buffer_auto_close(res);
        res->analysers &= ~an_bit;
        return 1;