From 573ead1e689ad8d1a80442b2c0d8759f9335a871 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Thu, 13 Apr 2023 15:39:30 +0200 Subject: [PATCH] MINOR: stconn: Rename SC_FL_SHUTR_NOW in SC_FL_ABRT_WANTED It is the first step to transform shutdown for reads for the upper layer into aborts. This patch is quite simple, it is just a flag renaming. --- include/haproxy/channel.h | 4 ++-- include/haproxy/stconn-t.h | 4 ++-- src/cli.c | 2 +- src/http_ana.c | 2 +- src/stream.c | 30 +++++++++++++++--------------- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/include/haproxy/channel.h b/include/haproxy/channel.h index 44728bbf6..4b9301659 100644 --- a/include/haproxy/channel.h +++ b/include/haproxy/channel.h @@ -551,7 +551,7 @@ static inline void channel_htx_erase(struct channel *chn, struct htx *htx) /* marks the channel as "shutdown" ASAP for reads */ static inline void channel_shutr_now(struct channel *chn) { - chn_prod(chn)->flags |= SC_FL_SHUTR_NOW; + chn_prod(chn)->flags |= SC_FL_ABRT_WANTED; } /* marks the channel as "shutdown" ASAP for writes */ @@ -563,7 +563,7 @@ static inline void channel_shutw_now(struct channel *chn) /* marks the channel as "shutdown" ASAP in both directions */ static inline void channel_abort(struct channel *chn) { - chn_prod(chn)->flags |= SC_FL_SHUTR_NOW; + chn_prod(chn)->flags |= SC_FL_ABRT_WANTED; chn_cons(chn)->flags |= SC_FL_SHUTW_NOW; chn->flags |= CF_AUTO_CLOSE; chn->flags &= ~CF_AUTO_CONNECT; diff --git a/include/haproxy/stconn-t.h b/include/haproxy/stconn-t.h index 63b882a6c..cfc2eeb98 100644 --- a/include/haproxy/stconn-t.h +++ b/include/haproxy/stconn-t.h @@ -158,7 +158,7 @@ enum sc_flags { SC_FL_SND_NEVERWAIT = 0x00001000, /* Never wait for sending (permanent) */ SC_FL_SND_EXP_MORE = 0x00001000, /* More data expected to be sent very soon. cleared when all data were sent */ - SC_FL_SHUTR_NOW = 0x00002000, /* SC is shut down for reads */ + SC_FL_ABRT_WANTED = 0x00002000, /* An abort was requested and must be performed ASAP */ SC_FL_SHUTW_NOW = 0x00004000, /* SC must shut down for reads ASAP */ SC_FL_SHUTR = 0x00008000, /* SC is shut down for writes */ SC_FL_SHUTW = 0x00010000, /* SC must shut down for writes ASAP */ @@ -178,7 +178,7 @@ static forceinline char *sc_show_flags(char *buf, size_t len, const char *delim, _(SC_FL_DONT_WAKE, _(SC_FL_INDEP_STR, _(SC_FL_WONT_READ, _(SC_FL_NEED_BUFF, _(SC_FL_NEED_ROOM, _(SC_FL_RCV_ONCE, _(SC_FL_SND_ASAP, _(SC_FL_SND_NEVERWAIT, _(SC_FL_SND_EXP_MORE, - _(SC_FL_SHUTR_NOW, _(SC_FL_SHUTW_NOW, _(SC_FL_SHUTR, _(SC_FL_SHUTW))))))))))))))))); + _(SC_FL_ABRT_WANTED, _(SC_FL_SHUTW_NOW, _(SC_FL_SHUTR, _(SC_FL_SHUTW))))))))))))))))); /* epilogue */ _(~0U); return buf; diff --git a/src/cli.c b/src/cli.c index 820a45adc..0de620351 100644 --- a/src/cli.c +++ b/src/cli.c @@ -2855,7 +2855,7 @@ int pcli_wait_for_response(struct stream *s, struct channel *rep, int an_bit) s->store_count = 0; s->uniq_id = global.req_count++; - s->scf->flags &= ~(SC_FL_SHUTR|SC_FL_SHUTR_NOW); + s->scf->flags &= ~(SC_FL_SHUTR|SC_FL_ABRT_WANTED); s->scf->flags &= ~SC_FL_SND_NEVERWAIT; s->scf->flags |= SC_FL_RCV_ONCE; /* one read is usually enough */ diff --git a/src/http_ana.c b/src/http_ana.c index 39da847c6..3ae76ed0d 100644 --- a/src/http_ana.c +++ b/src/http_ana.c @@ -1132,7 +1132,7 @@ static __inline int do_l7_retry(struct stream *s, struct stconn *sc) res = &s->res; /* Remove any write error from the request, and read error from the response */ - s->scf->flags &= ~(SC_FL_SHUTR|SC_FL_SHUTR_NOW); + s->scf->flags &= ~(SC_FL_SHUTR|SC_FL_ABRT_WANTED); req->flags &= ~CF_WRITE_TIMEOUT; res->flags &= ~(CF_READ_TIMEOUT | CF_READ_EVENT); res->analysers &= AN_RES_FLT_END; diff --git a/src/stream.c b/src/stream.c index e45b321b5..cef544f12 100644 --- a/src/stream.c +++ b/src/stream.c @@ -1954,7 +1954,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) resync_request: /* Analyse request */ if (((req->flags & ~rqf_last) & CF_MASK_ANALYSER) || - ((scf->flags ^ scf_flags) & (SC_FL_SHUTR|SC_FL_SHUTR_NOW)) || + ((scf->flags ^ scf_flags) & (SC_FL_SHUTR|SC_FL_ABRT_WANTED)) || ((scb->flags ^ scb_flags) & (SC_FL_SHUTW|SC_FL_SHUTW_NOW)) || (req->analysers && (chn_cons(req)->flags & SC_FL_SHUTW)) || scf->state != rq_prod_last || @@ -2042,7 +2042,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) rq_cons_last = scb->state; req->flags &= ~CF_WAKE_ONCE; rqf_last = req->flags; - scf_flags = (scf_flags & ~(SC_FL_SHUTR|SC_FL_SHUTR_NOW)) | (scf->flags & (SC_FL_SHUTR|SC_FL_SHUTR_NOW)); + scf_flags = (scf_flags & ~(SC_FL_SHUTR|SC_FL_ABRT_WANTED)) | (scf->flags & (SC_FL_SHUTR|SC_FL_ABRT_WANTED)); scb_flags = (scb_flags & ~(SC_FL_SHUTW|SC_FL_SHUTW_NOW)) | (scb->flags & (SC_FL_SHUTW|SC_FL_SHUTW_NOW)); if (((scf->flags ^ scf_flags_ana) & SC_FL_SHUTR) || ((scb->flags ^ scb_flags_ana) & SC_FL_SHUTW)) @@ -2059,7 +2059,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) /* Analyse response */ if (((res->flags & ~rpf_last) & CF_MASK_ANALYSER) || - ((scb->flags ^ scb_flags) & (SC_FL_SHUTR|SC_FL_SHUTR_NOW)) || + ((scb->flags ^ scb_flags) & (SC_FL_SHUTR|SC_FL_ABRT_WANTED)) || ((scf->flags ^ scf_flags) & (SC_FL_SHUTW|SC_FL_SHUTW_NOW)) || (res->analysers && (chn_cons(res)->flags & SC_FL_SHUTW)) || scf->state != rp_cons_last || @@ -2115,7 +2115,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) rp_prod_last = scb->state; res->flags &= ~CF_WAKE_ONCE; rpf_last = res->flags; - scb_flags = (scb_flags & ~(SC_FL_SHUTR|SC_FL_SHUTR_NOW)) | (scb->flags & (SC_FL_SHUTR|SC_FL_SHUTR_NOW)); + scb_flags = (scb_flags & ~(SC_FL_SHUTR|SC_FL_ABRT_WANTED)) | (scb->flags & (SC_FL_SHUTR|SC_FL_ABRT_WANTED)); scf_flags = (scf_flags & ~(SC_FL_SHUTW|SC_FL_SHUTW_NOW)) | (scf->flags & (SC_FL_SHUTW|SC_FL_SHUTW_NOW)); if (((scb->flags ^ scb_flags_ana) & SC_FL_SHUTR) || ((scf->flags ^ scf_flags_ana) & SC_FL_SHUTW)) @@ -2228,11 +2228,11 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) /* If no one is interested in analysing data, it's time to forward * everything. We configure the buffer to forward indefinitely. - * Note that we're checking SC_FL_SHUTR_NOW as an indication of a possible + * Note that we're checking SC_FL_ABRT_WANTED as an indication of a possible * recent call to channel_abort(). */ if (unlikely((!req->analysers || (req->analysers == AN_REQ_FLT_END && !(req->flags & CF_FLT_ANALYZE))) && - !(scf->flags & SC_FL_SHUTR_NOW) && !(scb->flags & SC_FL_SHUTW) && + !(scf->flags & SC_FL_ABRT_WANTED) && !(scb->flags & SC_FL_SHUTW) && (sc_state_in(scf->state, SC_SB_EST|SC_SB_DIS|SC_SB_CLO)) && (req->to_forward != CHN_INFINITE_FORWARD))) { /* This buffer is freewheeling, there's no analyser @@ -2283,7 +2283,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) /* reflect what the L7 analysers have seen last */ rqf_last = req->flags; - scf_flags = (scf_flags & ~(SC_FL_SHUTR|SC_FL_SHUTR_NOW)) | (scf->flags & (SC_FL_SHUTR|SC_FL_SHUTR_NOW)); + scf_flags = (scf_flags & ~(SC_FL_SHUTR|SC_FL_ABRT_WANTED)) | (scf->flags & (SC_FL_SHUTR|SC_FL_ABRT_WANTED)); scb_flags = (scb_flags & ~(SC_FL_SHUTW|SC_FL_SHUTW_NOW)) | (scb->flags & (SC_FL_SHUTW|SC_FL_SHUTW_NOW)); /* it's possible that an upper layer has requested a connection setup or abort. @@ -2379,12 +2379,12 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) } /* shutdown(write) done on server side, we must stop the client too */ - if (unlikely((scb->flags & SC_FL_SHUTW) && !(scf->flags & (SC_FL_SHUTR|SC_FL_SHUTR_NOW))) && + if (unlikely((scb->flags & SC_FL_SHUTW) && !(scf->flags & (SC_FL_SHUTR|SC_FL_ABRT_WANTED))) && !req->analysers) channel_shutr_now(req); /* shutdown(read) pending */ - if (unlikely((scf->flags & (SC_FL_SHUTR|SC_FL_SHUTR_NOW)) == SC_FL_SHUTR_NOW)) { + if (unlikely((scf->flags & (SC_FL_SHUTR|SC_FL_ABRT_WANTED)) == SC_FL_ABRT_WANTED)) { if (scf->flags & SC_FL_NOHALF) scf->flags |= SC_FL_NOLINGER; sc_shutr(scf); @@ -2405,11 +2405,11 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) /* If no one is interested in analysing data, it's time to forward * everything. We configure the buffer to forward indefinitely. - * Note that we're checking SC_FL_SHUTR_NOW as an indication of a possible + * Note that we're checking SC_FL_ABRT_WANTED as an indication of a possible * recent call to channel_abort(). */ if (unlikely((!res->analysers || (res->analysers == AN_RES_FLT_END && !(res->flags & CF_FLT_ANALYZE))) && - !(scf->flags & SC_FL_SHUTR_NOW) && !(scb->flags & SC_FL_SHUTW_NOW) && + !(scf->flags & SC_FL_ABRT_WANTED) && !(scb->flags & SC_FL_SHUTW_NOW) && sc_state_in(scb->state, SC_SB_EST|SC_SB_DIS|SC_SB_CLO) && (res->to_forward != CHN_INFINITE_FORWARD))) { /* This buffer is freewheeling, there's no analyser @@ -2472,7 +2472,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) /* reflect what the L7 analysers have seen last */ rpf_last = res->flags; - scb_flags = (scb_flags & ~(SC_FL_SHUTR|SC_FL_SHUTR_NOW)) | (scb->flags & (SC_FL_SHUTR|SC_FL_SHUTR_NOW)); + scb_flags = (scb_flags & ~(SC_FL_SHUTR|SC_FL_ABRT_WANTED)) | (scb->flags & (SC_FL_SHUTR|SC_FL_ABRT_WANTED)); scf_flags = (scf_flags & ~(SC_FL_SHUTW|SC_FL_SHUTW_NOW)) | (scf->flags & (SC_FL_SHUTW|SC_FL_SHUTW_NOW)); /* Let's see if we can send the pending response now */ @@ -2499,12 +2499,12 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) } /* shutdown(write) done on the client side, we must stop the server too */ - if (unlikely((scf->flags & SC_FL_SHUTW) && !(scb->flags & (SC_FL_SHUTR|SC_FL_SHUTR_NOW))) && + if (unlikely((scf->flags & SC_FL_SHUTW) && !(scb->flags & (SC_FL_SHUTR|SC_FL_ABRT_WANTED))) && !res->analysers) channel_shutr_now(res); /* shutdown(read) pending */ - if (unlikely((scb->flags & (SC_FL_SHUTR|SC_FL_SHUTR_NOW)) == SC_FL_SHUTR_NOW)) { + if (unlikely((scb->flags & (SC_FL_SHUTR|SC_FL_ABRT_WANTED)) == SC_FL_ABRT_WANTED)) { if (scb->flags & SC_FL_NOHALF) scb->flags |= SC_FL_NOLINGER; sc_shutr(scb); @@ -2519,7 +2519,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state) if ((req->flags & ~rqf_last) & CF_MASK_ANALYSER) goto resync_request; - if (((scb->flags ^ scb_flags) & (SC_FL_SHUTR|SC_FL_SHUTR_NOW)) || + if (((scb->flags ^ scb_flags) & (SC_FL_SHUTR|SC_FL_ABRT_WANTED)) || ((scf->flags ^ scf_flags) & (SC_FL_SHUTW|SC_FL_SHUTW_NOW))) goto resync_response;