]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: applet: use the appctx's endp instead of cs->endp
authorWilly Tarreau <w@1wt.eu>
Tue, 10 May 2022 09:32:31 +0000 (11:32 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 13 May 2022 12:28:46 +0000 (14:28 +0200)
The few applets that set CS_EP_EOI or CS_EP_ERROR used to set it on the
endpoint retrieved from the conn_stream while it's already available on
the appctx itself. Better use the appctx one to limit the unneeded
interactions between the two sides.

addons/promex/service-prometheus.c
src/applet.c
src/cache.c
src/cli.c
src/hlua.c
src/http_client.c
src/stats.c

index e247920cdcd34b8a2516ab4bb1cb3420276521d8..fb2fd9ce9fec98d82162af5572e6e08c03ceb3a1 100644 (file)
@@ -1563,8 +1563,8 @@ static void promex_appctx_handle_io(struct appctx *appctx)
                                channel_add_input(res, 1);
                        }
                        res_htx->flags |= HTX_FL_EOM;
-                       cs->endp->flags |= CS_EP_EOI;
                        res->flags |= CF_EOI;
+                       appctx->endp->flags |= CS_EP_EOI;
                        appctx->st0 = PROMEX_ST_END;
                        /* fall through */
 
index 381c36e6d7630c0bf8656d95a1f4b4b84ff008b7..9149af4431fd285a3154393e7f6c4f946be7230d 100644 (file)
@@ -106,7 +106,7 @@ int appctx_buf_available(void *arg)
        struct conn_stream *cs = appctx->owner;
 
        /* allocation requested ? */
-       if (!(cs->endp->flags & CS_EP_RXBLK_BUFF))
+       if (!(appctx->endp->flags & CS_EP_RXBLK_BUFF))
                return 0;
 
        cs_rx_buff_rdy(cs);
@@ -168,8 +168,8 @@ struct task *task_run_applet(struct task *t, void *context, unsigned int state)
        /* measure the call rate and check for anomalies when too high */
        rate = update_freq_ctr(&app->call_rate, 1);
        if (rate >= 100000 && app->call_rate.prev_ctr && // looped more than 100k times over last second
-           ((b_size(cs_ib(cs)) && cs->endp->flags & CS_EP_RXBLK_BUFF) || // asks for a buffer which is present
-            (b_size(cs_ib(cs)) && !b_data(cs_ib(cs)) && cs->endp->flags & CS_EP_RXBLK_ROOM) || // asks for room in an empty buffer
+           ((b_size(cs_ib(cs)) && app->endp->flags & CS_EP_RXBLK_BUFF) || // asks for a buffer which is present
+            (b_size(cs_ib(cs)) && !b_data(cs_ib(cs)) && app->endp->flags & CS_EP_RXBLK_ROOM) || // asks for room in an empty buffer
             (b_data(cs_ob(cs)) && cs_tx_endp_ready(cs) && !cs_tx_blocked(cs)) || // asks for data already present
             (!b_data(cs_ib(cs)) && b_data(cs_ob(cs)) && // didn't return anything ...
              (cs_oc(cs)->flags & (CF_WRITE_PARTIAL|CF_SHUTW_NOW)) == CF_SHUTW_NOW))) { // ... and left data pending after a shut
index f62aff84764bb186665ceefa8c1b43e5f84fb600..2e5c5a45bdf76caac17d32b7f3f868f28c44ee02 100644 (file)
@@ -1524,8 +1524,8 @@ static void http_cache_io_handler(struct appctx *appctx)
        if (appctx->st0 == HTX_CACHE_EOM) {
                 /* no more data are expected. */
                res_htx->flags |= HTX_FL_EOM;
-               cs->endp->flags |= CS_EP_EOI;
                res->flags |= CF_EOI;
+               appctx->endp->flags |= CS_EP_EOI;
                appctx->st0 = HTX_CACHE_END;
        }
 
index 1618aaec55eb73e4dcf7937ea084ad1f522f3728..30d24b8d3ac6d09ded9b8c091e2af3fb1cec7b81 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -1108,7 +1108,7 @@ static void cli_io_handler(struct appctx *appctx)
                                        }
                                break;
                        default: /* abnormal state */
-                               cs->endp->flags |= CS_EP_ERROR;
+                               appctx->endp->flags |= CS_EP_ERROR;
                                break;
                        }
 
index 2327553c842927621534065ad14fa07a5f6dc8a7..8d6fc35e27689359accb5c760dfac6d5a7e14a32 100644 (file)
@@ -9629,8 +9629,8 @@ void hlua_applet_http_fct(struct appctx *ctx)
                }
 
                res_htx->flags |= HTX_FL_EOM;
-               cs->endp->flags |= CS_EP_EOI;
                res->flags |= CF_EOI;
+               ctx->endp->flags |= CS_EP_EOI;
                strm->txn->status = http_ctx->status;
                http_ctx->flags |= APPLET_RSP_SENT;
        }
index 5d22044472b52e239d66d3e21e19064199222476..bff7057b17384d7d33b36133d77407fdde08bd38 100644 (file)
@@ -832,8 +832,8 @@ static void httpclient_applet_io_handler(struct appctx *appctx)
 
                                        /* if the request contains the HTX_FL_EOM, we finished the request part. */
                                        if (htx->flags & HTX_FL_EOM) {
-                                               cs->endp->flags |= CS_EP_EOI;
                                                req->flags |= CF_EOI;
+                                               appctx->endp->flags |= CS_EP_EOI;
                                                appctx->st0 = HTTPCLIENT_S_RES_STLINE;
                                        }
 
index bd73f483579097390c2a428103a6d16f95d344e6..aef9bac58977658b6703a389c6eb355eaefb637e 100644 (file)
@@ -4348,8 +4348,8 @@ static void http_stats_io_handler(struct appctx *appctx)
                        channel_add_input(res, 1);
                }
                res_htx->flags |= HTX_FL_EOM;
-               cs->endp->flags |= CS_EP_EOI;
                res->flags |= CF_EOI;
+               appctx->endp->flags |= CS_EP_EOI;
                appctx->st0 = STAT_HTTP_END;
        }