From: Willy Tarreau Date: Tue, 10 May 2022 09:32:31 +0000 (+0200) Subject: CLEANUP: applet: use the appctx's endp instead of cs->endp X-Git-Tag: v2.6-dev10~24 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=66435e5f6360adf5775e9d4852a9f1a2af56fe92;p=thirdparty%2Fhaproxy.git CLEANUP: applet: use the appctx's endp instead of cs->endp 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. --- diff --git a/addons/promex/service-prometheus.c b/addons/promex/service-prometheus.c index e247920cdc..fb2fd9ce9f 100644 --- a/addons/promex/service-prometheus.c +++ b/addons/promex/service-prometheus.c @@ -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 */ diff --git a/src/applet.c b/src/applet.c index 381c36e6d7..9149af4431 100644 --- a/src/applet.c +++ b/src/applet.c @@ -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 diff --git a/src/cache.c b/src/cache.c index f62aff8476..2e5c5a45bd 100644 --- a/src/cache.c +++ b/src/cache.c @@ -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; } diff --git a/src/cli.c b/src/cli.c index 1618aaec55..30d24b8d3a 100644 --- 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; } diff --git a/src/hlua.c b/src/hlua.c index 2327553c84..8d6fc35e27 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -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; } diff --git a/src/http_client.c b/src/http_client.c index 5d22044472..bff7057b17 100644 --- a/src/http_client.c +++ b/src/http_client.c @@ -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; } diff --git a/src/stats.c b/src/stats.c index bd73f48357..aef9bac589 100644 --- a/src/stats.c +++ b/src/stats.c @@ -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; }