mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 15:47:01 +02:00
MINOR: filters: Review and simplify errors handling
First, it is useless to abort the both channel explicitly. For HTTP streams, http_reply_and_close() is called. This function already take care to abort processing. For TCP streams, we can rely on stream_retnclose(). To set termination flags, we can also rely on http_set_term_flags() for HTTP streams and sess_set_term_flags() for TCP streams. Thus no reason to handle them by hand. At the end, the error handling after filters evaluation is now quite simple.
This commit is contained in:
parent
dbad8ec787
commit
0adffb62c1
@ -1050,9 +1050,6 @@ static int
|
|||||||
handle_analyzer_result(struct stream *s, struct channel *chn,
|
handle_analyzer_result(struct stream *s, struct channel *chn,
|
||||||
unsigned int an_bit, int ret)
|
unsigned int an_bit, int ret)
|
||||||
{
|
{
|
||||||
int finst;
|
|
||||||
int status = 0;
|
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto return_bad_req;
|
goto return_bad_req;
|
||||||
else if (!ret)
|
else if (!ret)
|
||||||
@ -1067,36 +1064,27 @@ handle_analyzer_result(struct stream *s, struct channel *chn,
|
|||||||
|
|
||||||
return_bad_req:
|
return_bad_req:
|
||||||
/* An error occurs */
|
/* An error occurs */
|
||||||
channel_abort(&s->req);
|
|
||||||
channel_abort(&s->res);
|
|
||||||
|
|
||||||
if (!(chn->flags & CF_ISRESP)) {
|
|
||||||
s->req.analysers &= AN_REQ_FLT_END;
|
|
||||||
finst = SF_FINST_R;
|
|
||||||
status = 400;
|
|
||||||
/* FIXME: incr counters */
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
s->res.analysers &= AN_RES_FLT_END;
|
|
||||||
finst = SF_FINST_H;
|
|
||||||
status = 502;
|
|
||||||
/* FIXME: incr counters */
|
|
||||||
}
|
|
||||||
|
|
||||||
if (IS_HTX_STRM(s)) {
|
if (IS_HTX_STRM(s)) {
|
||||||
/* Do not do that when we are waiting for the next request */
|
http_set_term_flags(s);
|
||||||
|
|
||||||
if (s->txn->status > 0)
|
if (s->txn->status > 0)
|
||||||
http_reply_and_close(s, s->txn->status, NULL);
|
http_reply_and_close(s, s->txn->status, NULL);
|
||||||
else {
|
else {
|
||||||
s->txn->status = status;
|
s->txn->status = (!(chn->flags & CF_ISRESP)) ? 400 : 502;
|
||||||
http_reply_and_close(s, status, http_error_message(s));
|
http_reply_and_close(s, s->txn->status, http_error_message(s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
sess_set_term_flags(s);
|
||||||
|
stream_retnclose(s, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(chn->flags & CF_ISRESP))
|
||||||
|
s->req.analysers &= AN_REQ_FLT_END;
|
||||||
|
else
|
||||||
|
s->res.analysers &= AN_RES_FLT_END;
|
||||||
|
|
||||||
|
|
||||||
if (!(s->flags & SF_ERR_MASK))
|
|
||||||
s->flags |= SF_ERR_PRXCOND;
|
|
||||||
if (!(s->flags & SF_FINST_MASK))
|
|
||||||
s->flags |= finst;
|
|
||||||
DBG_TRACE_DEVEL("leaving on error", STRM_EV_FLT_ANA|STRM_EV_FLT_ERR, s);
|
DBG_TRACE_DEVEL("leaving on error", STRM_EV_FLT_ANA|STRM_EV_FLT_ERR, s);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user