MINOR: tree-wide: Replace several chn_cons() by the corresponding SC

At many places, call to chn_cons() can be easily replaced by the
corresponding SC. It is a bit easier to understand which side is
manipulated.
This commit is contained in:
Christopher Faulet 2023-04-13 16:37:37 +02:00
parent b2b1c3a6ea
commit 64350bbf05
5 changed files with 19 additions and 21 deletions

View File

@ -1956,7 +1956,7 @@ int srv_redispatch_connect(struct stream *s)
static int back_may_abort_req(struct channel *req, struct stream *s) static int back_may_abort_req(struct channel *req, struct stream *s)
{ {
return (sc_ep_test(s->scf, SE_FL_ERROR) || return (sc_ep_test(s->scf, SE_FL_ERROR) ||
((chn_cons(req)->flags & (SC_FL_SHUT_WANTED|SC_FL_SHUT_DONE)) && /* empty and client aborted */ ((s->scb->flags & (SC_FL_SHUT_WANTED|SC_FL_SHUT_DONE)) && /* empty and client aborted */
(channel_is_empty(req) || (s->be->options & PR_O_ABRT_CLOSE)))); (channel_is_empty(req) || (s->be->options & PR_O_ABRT_CLOSE))));
} }
@ -2241,13 +2241,12 @@ void back_handle_st_con(struct stream *s)
{ {
struct stconn *sc = s->scb; struct stconn *sc = s->scb;
struct channel *req = &s->req; struct channel *req = &s->req;
struct channel *rep = &s->res;
DBG_TRACE_ENTER(STRM_EV_STRM_PROC|STRM_EV_CS_ST, s); DBG_TRACE_ENTER(STRM_EV_STRM_PROC|STRM_EV_CS_ST, s);
/* the client might want to abort */ /* the client might want to abort */
if ((chn_cons(rep)->flags & SC_FL_SHUT_DONE) || if ((s->scf->flags & SC_FL_SHUT_DONE) ||
((chn_cons(req)->flags & SC_FL_SHUT_WANTED) && ((s->scb->flags & SC_FL_SHUT_WANTED) &&
(channel_is_empty(req) || (s->be->options & PR_O_ABRT_CLOSE)))) { (channel_is_empty(req) || (s->be->options & PR_O_ABRT_CLOSE)))) {
sc->flags |= SC_FL_NOLINGER; sc->flags |= SC_FL_NOLINGER;
sc_shutdown(sc); sc_shutdown(sc);
@ -2434,7 +2433,6 @@ void back_handle_st_rdy(struct stream *s)
{ {
struct stconn *sc = s->scb; struct stconn *sc = s->scb;
struct channel *req = &s->req; struct channel *req = &s->req;
struct channel *rep = &s->res;
DBG_TRACE_ENTER(STRM_EV_STRM_PROC|STRM_EV_CS_ST, s); DBG_TRACE_ENTER(STRM_EV_STRM_PROC|STRM_EV_CS_ST, s);
@ -2470,8 +2468,8 @@ void back_handle_st_rdy(struct stream *s)
*/ */
if (!(req->flags & CF_WROTE_DATA)) { if (!(req->flags & CF_WROTE_DATA)) {
/* client abort ? */ /* client abort ? */
if ((chn_cons(rep)->flags & SC_FL_SHUT_DONE) || if ((s->scf->flags & SC_FL_SHUT_DONE) ||
((chn_cons(req)->flags & SC_FL_SHUT_WANTED) && ((s->scb->flags & SC_FL_SHUT_WANTED) &&
(channel_is_empty(req) || (s->be->options & PR_O_ABRT_CLOSE)))) { (channel_is_empty(req) || (s->be->options & PR_O_ABRT_CLOSE)))) {
/* give up */ /* give up */
sc->flags |= SC_FL_NOLINGER; sc->flags |= SC_FL_NOLINGER;

View File

@ -2716,7 +2716,7 @@ int pcli_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
struct proxy *be = s->be; struct proxy *be = s->be;
if (sc_ep_test(s->scb, SE_FL_ERR_PENDING|SE_FL_ERROR) || (rep->flags & (CF_READ_TIMEOUT|CF_WRITE_TIMEOUT)) || if (sc_ep_test(s->scb, SE_FL_ERR_PENDING|SE_FL_ERROR) || (rep->flags & (CF_READ_TIMEOUT|CF_WRITE_TIMEOUT)) ||
((chn_cons(rep)->flags & SC_FL_SHUT_DONE) && (rep->to_forward || co_data(rep)))) { ((s->scf->flags & SC_FL_SHUT_DONE) && (rep->to_forward || co_data(rep)))) {
pcli_reply_and_close(s, "Can't connect to the target CLI!\n"); pcli_reply_and_close(s, "Can't connect to the target CLI!\n");
s->req.analysers &= ~AN_REQ_WAIT_CLI; s->req.analysers &= ~AN_REQ_WAIT_CLI;
s->res.analysers &= ~AN_RES_WAIT_CLI; s->res.analysers &= ~AN_RES_WAIT_CLI;

View File

@ -983,7 +983,7 @@ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit)
if (!(txn->flags & TX_CON_WANT_TUN)) if (!(txn->flags & TX_CON_WANT_TUN))
channel_dont_close(req); channel_dont_close(req);
if ((chn_cons(req)->flags & SC_FL_SHUT_DONE) && co_data(req)) { if ((s->scb->flags & SC_FL_SHUT_DONE) && co_data(req)) {
/* request errors are most likely due to the server aborting the /* request errors are most likely due to the server aborting the
* transfer. */ * transfer. */
goto return_srv_abort; goto return_srv_abort;
@ -1023,7 +1023,7 @@ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit)
waiting: waiting:
/* waiting for the last bits to leave the buffer */ /* waiting for the last bits to leave the buffer */
if (chn_cons(req)->flags & SC_FL_SHUT_DONE) if (s->scb->flags & SC_FL_SHUT_DONE)
goto return_srv_abort; goto return_srv_abort;
/* When TE: chunked is used, we need to get there again to parse remaining /* When TE: chunked is used, we need to get there again to parse remaining
@ -1296,7 +1296,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
/* 3: client abort with an abortonclose */ /* 3: client abort with an abortonclose */
else if ((chn_prod(rep)->flags & SC_FL_ABRT_DONE) && else if ((chn_prod(rep)->flags & SC_FL_ABRT_DONE) &&
(chn_prod(&s->req)->flags & SC_FL_ABRT_DONE) && (chn_prod(&s->req)->flags & SC_FL_ABRT_DONE) &&
(chn_cons(&s->req)->flags & SC_FL_SHUT_DONE)) { (s->scb->flags & SC_FL_SHUT_DONE)) {
_HA_ATOMIC_INC(&sess->fe->fe_counters.cli_aborts); _HA_ATOMIC_INC(&sess->fe->fe_counters.cli_aborts);
_HA_ATOMIC_INC(&s->be->be_counters.cli_aborts); _HA_ATOMIC_INC(&s->be->be_counters.cli_aborts);
if (sess->listener && sess->listener->counters) if (sess->listener && sess->listener->counters)
@ -2104,7 +2104,7 @@ int http_response_forward_body(struct stream *s, struct channel *res, int an_bit
channel_dont_close(res); channel_dont_close(res);
if ((chn_cons(res)->flags & SC_FL_SHUT_DONE) && co_data(res)) { if ((s->scf->flags & SC_FL_SHUT_DONE) && co_data(res)) {
/* response errors are most likely due to the client aborting /* response errors are most likely due to the client aborting
* the transfer. */ * the transfer. */
goto return_cli_abort; goto return_cli_abort;
@ -2120,7 +2120,7 @@ int http_response_forward_body(struct stream *s, struct channel *res, int an_bit
return 0; return 0;
missing_data_or_waiting: missing_data_or_waiting:
if (chn_cons(res)->flags & SC_FL_SHUT_DONE) if (s->scf->flags & SC_FL_SHUT_DONE)
goto return_cli_abort; goto return_cli_abort;
/* stop waiting for data if the input is closed before the end. If the /* stop waiting for data if the input is closed before the end. If the
@ -2130,7 +2130,7 @@ int http_response_forward_body(struct stream *s, struct channel *res, int an_bit
*/ */
if (msg->msg_state < HTTP_MSG_ENDING && (chn_prod(res)->flags & SC_FL_ABRT_DONE)) { if (msg->msg_state < HTTP_MSG_ENDING && (chn_prod(res)->flags & SC_FL_ABRT_DONE)) {
if ((chn_prod(&s->req)->flags & SC_FL_ABRT_DONE) && if ((chn_prod(&s->req)->flags & SC_FL_ABRT_DONE) &&
(chn_cons(&s->req)->flags & SC_FL_SHUT_DONE)) (s->scb->flags & SC_FL_SHUT_DONE))
goto return_cli_abort; goto return_cli_abort;
/* If we have some pending data, we continue the processing */ /* If we have some pending data, we continue the processing */
if (htx_is_empty(htx)) if (htx_is_empty(htx))
@ -4272,7 +4272,7 @@ static void http_end_request(struct stream *s)
txn->rsp.msg_state != HTTP_MSG_CLOSED) txn->rsp.msg_state != HTTP_MSG_CLOSED)
goto check_channel_flags; goto check_channel_flags;
if (!(chn_cons(chn)->flags & (SC_FL_SHUT_DONE|SC_FL_SHUT_WANTED))) { if (!(s->scb->flags & (SC_FL_SHUT_DONE|SC_FL_SHUT_WANTED))) {
sc_schedule_abort(s->scf); sc_schedule_abort(s->scf);
sc_schedule_shutdown(s->scb); sc_schedule_shutdown(s->scb);
} }
@ -4306,7 +4306,7 @@ static void http_end_request(struct stream *s)
check_channel_flags: check_channel_flags:
/* Here, we are in HTTP_MSG_DONE or HTTP_MSG_TUNNEL */ /* Here, we are in HTTP_MSG_DONE or HTTP_MSG_TUNNEL */
if (chn_cons(chn)->flags & (SC_FL_SHUT_DONE|SC_FL_SHUT_WANTED)) { if (s->scb->flags & (SC_FL_SHUT_DONE|SC_FL_SHUT_WANTED)) {
/* if we've just closed an output, let's switch */ /* if we've just closed an output, let's switch */
txn->req.msg_state = HTTP_MSG_CLOSING; txn->req.msg_state = HTTP_MSG_CLOSING;
goto http_msg_closing; goto http_msg_closing;
@ -4371,7 +4371,7 @@ static void http_end_response(struct stream *s)
/* we're not expecting any new data to come for this /* we're not expecting any new data to come for this
* transaction, so we can close it. * transaction, so we can close it.
*/ */
if (!(chn_cons(chn)->flags & (SC_FL_SHUT_DONE|SC_FL_SHUT_WANTED))) { if (!(s->scf->flags & (SC_FL_SHUT_DONE|SC_FL_SHUT_WANTED))) {
sc_schedule_abort(s->scb); sc_schedule_abort(s->scb);
sc_schedule_shutdown(s->scf); sc_schedule_shutdown(s->scf);
} }
@ -4402,7 +4402,7 @@ static void http_end_response(struct stream *s)
check_channel_flags: check_channel_flags:
/* Here, we are in HTTP_MSG_DONE or HTTP_MSG_TUNNEL */ /* Here, we are in HTTP_MSG_DONE or HTTP_MSG_TUNNEL */
if (chn_cons(chn)->flags & (SC_FL_SHUT_DONE|SC_FL_SHUT_WANTED)) { if (s->scf->flags & (SC_FL_SHUT_DONE|SC_FL_SHUT_WANTED)) {
/* if we've just closed an output, let's switch */ /* if we've just closed an output, let's switch */
txn->rsp.msg_state = HTTP_MSG_CLOSING; txn->rsp.msg_state = HTTP_MSG_CLOSING;
goto http_msg_closing; goto http_msg_closing;

View File

@ -1369,7 +1369,7 @@ static int sc_conn_recv(struct stconn *sc)
cur_read += ret; cur_read += ret;
/* if we're allowed to directly forward data, we must update ->o */ /* if we're allowed to directly forward data, we must update ->o */
if (ic->to_forward && !(chn_cons(ic)->flags & (SC_FL_SHUT_DONE|SC_FL_SHUT_WANTED))) { if (ic->to_forward && !(sc_opposite(sc)->flags & (SC_FL_SHUT_DONE|SC_FL_SHUT_WANTED))) {
unsigned long fwd = ret; unsigned long fwd = ret;
if (ic->to_forward != CHN_INFINITE_FORWARD) { if (ic->to_forward != CHN_INFINITE_FORWARD) {
if (fwd > ic->to_forward) if (fwd > ic->to_forward)

View File

@ -1956,7 +1956,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
if (((req->flags & ~rqf_last) & CF_MASK_ANALYSER) || if (((req->flags & ~rqf_last) & CF_MASK_ANALYSER) ||
((scf->flags ^ scf_flags) & (SC_FL_ABRT_DONE|SC_FL_ABRT_WANTED)) || ((scf->flags ^ scf_flags) & (SC_FL_ABRT_DONE|SC_FL_ABRT_WANTED)) ||
((scb->flags ^ scb_flags) & (SC_FL_SHUT_DONE|SC_FL_SHUT_WANTED)) || ((scb->flags ^ scb_flags) & (SC_FL_SHUT_DONE|SC_FL_SHUT_WANTED)) ||
(req->analysers && (chn_cons(req)->flags & SC_FL_SHUT_DONE)) || (req->analysers && (scb->flags & SC_FL_SHUT_DONE)) ||
scf->state != rq_prod_last || scf->state != rq_prod_last ||
scb->state != rq_cons_last || scb->state != rq_cons_last ||
s->pending_events & TASK_WOKEN_MSG) { s->pending_events & TASK_WOKEN_MSG) {
@ -2061,7 +2061,7 @@ struct task *process_stream(struct task *t, void *context, unsigned int state)
if (((res->flags & ~rpf_last) & CF_MASK_ANALYSER) || if (((res->flags & ~rpf_last) & CF_MASK_ANALYSER) ||
((scb->flags ^ scb_flags) & (SC_FL_ABRT_DONE|SC_FL_ABRT_WANTED)) || ((scb->flags ^ scb_flags) & (SC_FL_ABRT_DONE|SC_FL_ABRT_WANTED)) ||
((scf->flags ^ scf_flags) & (SC_FL_SHUT_DONE|SC_FL_SHUT_WANTED)) || ((scf->flags ^ scf_flags) & (SC_FL_SHUT_DONE|SC_FL_SHUT_WANTED)) ||
(res->analysers && (chn_cons(res)->flags & SC_FL_SHUT_DONE)) || (res->analysers && (scf->flags & SC_FL_SHUT_DONE)) ||
scf->state != rp_cons_last || scf->state != rp_cons_last ||
scb->state != rp_prod_last || scb->state != rp_prod_last ||
s->pending_events & TASK_WOKEN_MSG) { s->pending_events & TASK_WOKEN_MSG) {