mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-10-27 22:51:02 +01:00
MINOR: proxy: only check abortonclose through a dedicated function
In order to prepare for changing the way abortonclose works, let's replace the direct flag check with a similarly named function (proxy_abrt_close) which returns the on/off status of the directive for the proxy. For now it simply reflects the flag's state.
This commit is contained in:
parent
687504344a
commit
fe47e8dfc5
@ -141,6 +141,12 @@ static inline void proxy_reset_timeouts(struct proxy *proxy)
|
||||
proxy->timeout.tunnel = TICK_ETERNITY;
|
||||
}
|
||||
|
||||
/* return proxy's abortonclose status: 0=off, non-zero=on */
|
||||
static inline int proxy_abrt_close(const struct proxy *px)
|
||||
{
|
||||
return !!(px->options & PR_O_ABRT_CLOSE);
|
||||
}
|
||||
|
||||
/* increase the number of cumulated connections received on the designated frontend */
|
||||
static inline void proxy_inc_fe_conn_ctr(struct listener *l, struct proxy *fe)
|
||||
{
|
||||
|
||||
@ -2387,7 +2387,7 @@ static int back_may_abort_req(struct channel *req, struct stream *s)
|
||||
{
|
||||
return ((s->scf->flags & SC_FL_ERROR) ||
|
||||
((s->scb->flags & (SC_FL_SHUT_WANTED|SC_FL_SHUT_DONE)) && /* empty and client aborted */
|
||||
(!co_data(req) || (s->be->options & PR_O_ABRT_CLOSE))));
|
||||
(!co_data(req) || proxy_abrt_close(s->be))));
|
||||
}
|
||||
|
||||
/* Update back stream connector status for input states SC_ST_ASS, SC_ST_QUE,
|
||||
@ -2679,7 +2679,7 @@ void back_handle_st_con(struct stream *s)
|
||||
/* the client might want to abort */
|
||||
if ((s->scf->flags & SC_FL_SHUT_DONE) ||
|
||||
((s->scb->flags & SC_FL_SHUT_WANTED) &&
|
||||
(!co_data(req) || (s->be->options & PR_O_ABRT_CLOSE)))) {
|
||||
(!co_data(req) || proxy_abrt_close(s->be)))) {
|
||||
sc->flags |= SC_FL_NOLINGER;
|
||||
sc_shutdown(sc);
|
||||
s->conn_err_type |= STRM_ET_CONN_ABRT;
|
||||
@ -2904,7 +2904,7 @@ void back_handle_st_rdy(struct stream *s)
|
||||
/* client abort ? */
|
||||
if ((s->scf->flags & SC_FL_SHUT_DONE) ||
|
||||
((s->scb->flags & SC_FL_SHUT_WANTED) &&
|
||||
(!co_data(req) || (s->be->options & PR_O_ABRT_CLOSE)))) {
|
||||
(!co_data(req) || proxy_abrt_close(s->be)))) {
|
||||
/* give up */
|
||||
sc->flags |= SC_FL_NOLINGER;
|
||||
sc_shutdown(sc);
|
||||
|
||||
@ -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 (s->be->options & PR_O_ABRT_CLOSE) {
|
||||
if (proxy_abrt_close(s->be)) {
|
||||
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)) &&
|
||||
(px->options & PR_O_ABRT_CLOSE)))
|
||||
proxy_abrt_close(px)))
|
||||
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)) &&
|
||||
(px->options & PR_O_ABRT_CLOSE)))
|
||||
proxy_abrt_close(px)))
|
||||
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 (!(s->be->options & PR_O_ABRT_CLOSE) && txn->meth != HTTP_METH_POST)
|
||||
if (!proxy_abrt_close(s->be) && 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 (!(s->be->options & PR_O_ABRT_CLOSE))
|
||||
if (!proxy_abrt_close(s->be))
|
||||
channel_dont_read(chn);
|
||||
goto end;
|
||||
}
|
||||
|
||||
@ -385,7 +385,7 @@ static int ha_ssl_read(BIO *h, char *buf, int size)
|
||||
|
||||
if (ctx->conn->flags & CO_FL_SSL_WAIT_HS &&
|
||||
!conn_is_back(ctx->conn) &&
|
||||
((struct session *)ctx->conn->owner)->fe->options & PR_O_ABRT_CLOSE)
|
||||
proxy_abrt_close(((struct session *)ctx->conn->owner)->fe))
|
||||
detect_shutr = 1;
|
||||
else
|
||||
detect_shutr = 0;
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include <haproxy/http_ana.h>
|
||||
#include <haproxy/pipe.h>
|
||||
#include <haproxy/pool.h>
|
||||
#include <haproxy/proxy.h>
|
||||
#include <haproxy/sample.h>
|
||||
#include <haproxy/sc_strm.h>
|
||||
#include <haproxy/stconn.h>
|
||||
@ -1387,7 +1388,7 @@ int sc_conn_recv(struct stconn *sc)
|
||||
/* Instruct the mux it must subscribed for read events */
|
||||
if (!(sc->flags & SC_FL_ISBACK) && /* for frontend conns only */
|
||||
(sc_opposite(sc)->state != SC_ST_INI) && /* before backend connection setup */
|
||||
(__sc_strm(sc)->be->options & PR_O_ABRT_CLOSE)) /* if abortonclose option is set for the current backend */
|
||||
proxy_abrt_close(__sc_strm(sc)->be)) /* if abortonclose option is set for the current backend */
|
||||
flags |= CO_RFL_KEEP_RECV;
|
||||
|
||||
/* Important note : if we're called with POLL_IN|POLL_HUP, it means the read polling
|
||||
|
||||
@ -2355,7 +2355,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
|
||||
!(s->txn->flags & TX_D_L7_RETRY))
|
||||
s->txn->flags |= TX_L7_RETRY;
|
||||
|
||||
if (s->be->options & PR_O_ABRT_CLOSE) {
|
||||
if (proxy_abrt_close(s->be)) {
|
||||
struct connection *conn = sc_conn(scf);
|
||||
|
||||
se_have_more_data(scf->sedesc);
|
||||
@ -2425,7 +2425,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
|
||||
*/
|
||||
if (unlikely((req->flags & CF_AUTO_CLOSE) && (scf->flags & (SC_FL_EOS|SC_FL_ABRT_DONE)) &&
|
||||
!(scb->flags & (SC_FL_SHUT_DONE|SC_FL_SHUT_WANTED)) &&
|
||||
(scb->state != SC_ST_CON || (s->be->options & PR_O_ABRT_CLOSE)))) {
|
||||
(scb->state != SC_ST_CON || proxy_abrt_close(s->be)))) {
|
||||
sc_schedule_shutdown(scb);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user