MINOR: proxy: introduce proxy_abrt_close_def() to pass the desired default

With this function we can now pass the desired default value for the
abortonclose option when neither the option nor its opposite were set.
Let's also take this opportunity for using it directly from the HTTP
analyser since there's no point in re-checking the proxy's mode there.
This commit is contained in:
Willy Tarreau 2025-10-08 10:27:45 +02:00
parent 644b3dc7d8
commit 75103e7701
2 changed files with 18 additions and 10 deletions

View File

@ -141,18 +141,26 @@ static inline void proxy_reset_timeouts(struct proxy *proxy)
proxy->timeout.tunnel = TICK_ETERNITY;
}
/* return proxy's abortonclose status: 0=off, non-zero=on.
* Considers the proxy's mode when neither on/off was set,
* and HTTP mode defaults to on.
/* Return proxy's abortonclose status: 0=off, non-zero=on, with a default to
* <def> when neither choice was forced.
*/
static inline int proxy_abrt_close(const struct proxy *px)
static inline int proxy_abrt_close_def(const struct proxy *px, int def)
{
if (px->options & PR_O_ABRT_CLOSE)
return 1;
else if (px->no_options & PR_O_ABRT_CLOSE)
return 0;
/* When unset: 1 for HTTP, 0 for TCP */
return px->mode == PR_MODE_HTTP;
return def;
}
/* return proxy's abortonclose status: 0=off, non-zero=on.
* Considers the proxy's mode when neither on/off was set,
* and HTTP mode defaults to on.
*/
static inline int proxy_abrt_close(const struct proxy *px)
{
return proxy_abrt_close_def(px, px->mode == PR_MODE_HTTP);
}
/* increase the number of cumulated connections received on the designated frontend */

View File

@ -1055,7 +1055,7 @@ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit)
* server, which will decide whether to close or to go on processing the
* request. We only do that in tunnel mode, and not in other modes since
* it can be abused to exhaust source ports. */
if (proxy_abrt_close(s->be)) {
if (proxy_abrt_close_def(s->be, 1)) {
channel_auto_read(req);
if ((s->scf->flags & (SC_FL_ABRT_DONE|SC_FL_EOS)) && !(txn->flags & TX_CON_WANT_TUN))
s->scb->flags |= SC_FL_NOLINGER;
@ -2806,7 +2806,7 @@ static enum rule_result http_req_get_intercept_rule(struct proxy *px, struct lis
if ((s->scf->flags & SC_FL_ERROR) ||
((s->scf->flags & (SC_FL_EOS|SC_FL_ABRT_DONE)) &&
proxy_abrt_close(px)))
proxy_abrt_close_def(px, 1)))
act_opts |= ACT_OPT_FINAL | ACT_OPT_FINAL_EARLY;
/* If "the current_rule_list" match the executed rule list, we are in
@ -2994,7 +2994,7 @@ static enum rule_result http_res_get_intercept_rule(struct proxy *px, struct lis
act_opts |= ACT_OPT_FINAL;
if ((s->scf->flags & SC_FL_ERROR) ||
((s->scf->flags & (SC_FL_EOS|SC_FL_ABRT_DONE)) &&
proxy_abrt_close(px)))
proxy_abrt_close_def(px, 1)))
act_opts |= ACT_OPT_FINAL | ACT_OPT_FINAL_EARLY;
/* If "the current_rule_list" match the executed rule list, we are in
@ -4457,7 +4457,7 @@ static void http_end_request(struct stream *s)
* buffers, otherwise a close could cause an RST on some systems
* (eg: Linux).
*/
if (!proxy_abrt_close(s->be) && txn->meth != HTTP_METH_POST)
if (!proxy_abrt_close_def(s->be, 1) && txn->meth != HTTP_METH_POST)
channel_dont_read(chn);
/* if the server closes the connection, we want to immediately react
@ -4536,7 +4536,7 @@ static void http_end_request(struct stream *s)
if (txn->rsp.flags & HTTP_MSGF_XFER_LEN)
s->scb->flags |= SC_FL_NOLINGER; /* we want to close ASAP */
/* see above in MSG_DONE why we only do this in these states */
if (!proxy_abrt_close(s->be))
if (!proxy_abrt_close_def(s->be, 1))
channel_dont_read(chn);
goto end;
}