]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: tree-wide: Replace several chn_cons() by the corresponding SC
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 13 Apr 2023 14:37:37 +0000 (16:37 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 14 Apr 2023 13:04:03 +0000 (15:04 +0200)
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.

src/backend.c
src/cli.c
src/http_ana.c
src/stconn.c
src/stream.c

index 7044ae18189c50d9a71f5a6952802a160cb16a4d..7bc321b1c3b1237b1b50d1ee4d3523303c0b8f4f 100644 (file)
@@ -1956,7 +1956,7 @@ int srv_redispatch_connect(struct stream *s)
 static int back_may_abort_req(struct channel *req, struct stream *s)
 {
        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))));
 }
 
@@ -2241,13 +2241,12 @@ void back_handle_st_con(struct stream *s)
 {
        struct stconn *sc = s->scb;
        struct channel *req = &s->req;
-       struct channel *rep = &s->res;
 
        DBG_TRACE_ENTER(STRM_EV_STRM_PROC|STRM_EV_CS_ST, s);
 
        /* the client might want to abort */
-       if ((chn_cons(rep)->flags & SC_FL_SHUT_DONE) ||
-           ((chn_cons(req)->flags & SC_FL_SHUT_WANTED) &&
+       if ((s->scf->flags & SC_FL_SHUT_DONE) ||
+           ((s->scb->flags & SC_FL_SHUT_WANTED) &&
             (channel_is_empty(req) || (s->be->options & PR_O_ABRT_CLOSE)))) {
                sc->flags |= SC_FL_NOLINGER;
                sc_shutdown(sc);
@@ -2434,7 +2433,6 @@ void back_handle_st_rdy(struct stream *s)
 {
        struct stconn *sc = s->scb;
        struct channel *req = &s->req;
-       struct channel *rep = &s->res;
 
        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)) {
                /* client abort ? */
-               if ((chn_cons(rep)->flags & SC_FL_SHUT_DONE) ||
-                   ((chn_cons(req)->flags & SC_FL_SHUT_WANTED) &&
+               if ((s->scf->flags & SC_FL_SHUT_DONE) ||
+                   ((s->scb->flags & SC_FL_SHUT_WANTED) &&
                     (channel_is_empty(req) || (s->be->options & PR_O_ABRT_CLOSE)))) {
                        /* give up */
                        sc->flags |= SC_FL_NOLINGER;
index bcb4ce7cb402f7d5caf1082027c5dc869fc10c84..5ac493580f61cbe62b1d354cc9159e2645273154 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -2716,7 +2716,7 @@ int pcli_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
        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)) ||
-           ((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");
                s->req.analysers &= ~AN_REQ_WAIT_CLI;
                s->res.analysers &= ~AN_RES_WAIT_CLI;
index 61b5443977979b2fd324e9ef18f24de23bb268cb..3c46f2af950e6d7c1d602e37d02846cd1fce6e06 100644 (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))
                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
                 * transfer. */
                goto return_srv_abort;
@@ -1023,7 +1023,7 @@ int http_request_forward_body(struct stream *s, struct channel *req, int an_bit)
 
  waiting:
        /* 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;
 
        /* 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 */
                else if ((chn_prod(rep)->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(&s->be->be_counters.cli_aborts);
                        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);
 
-       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
                 * the transfer. */
                goto return_cli_abort;
@@ -2120,7 +2120,7 @@ int http_response_forward_body(struct stream *s, struct channel *res, int an_bit
        return 0;
 
   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;
 
        /* 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 ((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;
                /* If we have some pending data, we continue the processing */
                if (htx_is_empty(htx))
@@ -4272,7 +4272,7 @@ static void http_end_request(struct stream *s)
                            txn->rsp.msg_state != HTTP_MSG_CLOSED)
                                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_shutdown(s->scb);
                        }
@@ -4306,7 +4306,7 @@ static void http_end_request(struct stream *s)
 
   check_channel_flags:
        /* 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 */
                txn->req.msg_state = 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
                         * 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_shutdown(s->scf);
                        }
@@ -4402,7 +4402,7 @@ static void http_end_response(struct stream *s)
 
   check_channel_flags:
        /* 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 */
                txn->rsp.msg_state = HTTP_MSG_CLOSING;
                goto http_msg_closing;
index d320173bb5158e049ff40c6c45527d878e0bc5b7..eca1e457570623756d9df23795dafb1935c5b5da 100644 (file)
@@ -1369,7 +1369,7 @@ static int sc_conn_recv(struct stconn *sc)
                cur_read += ret;
 
                /* 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;
                        if (ic->to_forward != CHN_INFINITE_FORWARD) {
                                if (fwd > ic->to_forward)
index 83e3b72810d268db6ae9f2f2493e0483392b78f2..9c3361f3a38b7690046ad6608258546b8b93e072 100644 (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) ||
            ((scf->flags ^ scf_flags) & (SC_FL_ABRT_DONE|SC_FL_ABRT_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 ||
            scb->state != rq_cons_last ||
            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) ||
            ((scb->flags ^ scb_flags) & (SC_FL_ABRT_DONE|SC_FL_ABRT_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 ||
            scb->state != rp_prod_last ||
            s->pending_events & TASK_WOKEN_MSG) {