From 6c2cbe14e4bea0f7aafa4923e723ddfee6e0e2aa Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 3 Jan 2010 17:07:49 +0100 Subject: [PATCH] [BUG] http: take care of errors, timeouts and aborts during the data phase 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 | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/proto_http.c b/src/proto_http.c index 1648083d4..2cab1989d 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -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;