From 11921e6819a07219e8ed6adbdd276bdbdcdb324d Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Wed, 3 Jul 2019 11:43:17 +0200 Subject: [PATCH] BUG/MINOR: contrib/prometheus-exporter: Respect the reserve when data are sent The previous commit e6cdfe574 ("BUG/MINOR: contrib/prometheus-exporter: Don't use channel_htx_recv_max()") is buggy. The buffer's reserve must be respected. This patch must be backported to 2.0 and 1.9. --- contrib/prometheus-exporter/service-prometheus.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/contrib/prometheus-exporter/service-prometheus.c b/contrib/prometheus-exporter/service-prometheus.c index 60de8b418..b57af9944 100644 --- a/contrib/prometheus-exporter/service-prometheus.c +++ b/contrib/prometheus-exporter/service-prometheus.c @@ -1214,7 +1214,7 @@ static int promex_dump_global_metrics(struct appctx *appctx, struct htx *htx) struct field metric; struct channel *chn = si_ic(appctx->owner); struct ist out = ist2(trash.area, 0); - size_t max = htx_free_data_space(htx); + size_t max = htx_get_max_blksz(htx, channel_htx_recv_max(chn, htx)); int ret = 1; #ifdef USE_OPENSSL @@ -1227,7 +1227,6 @@ static int promex_dump_global_metrics(struct appctx *appctx, struct htx *htx) ssl_reuse = 100 - (100 * ssl_key_rate + (ssl_sess_rate - 1) / 2) / ssl_sess_rate; } #endif - while (appctx->st2 && appctx->st2 < INF_TOTAL_FIELDS) { switch (appctx->st2) { case INF_NBTHREAD: @@ -1427,7 +1426,7 @@ static int promex_dump_front_metrics(struct appctx *appctx, struct htx *htx) struct field metric; struct channel *chn = si_ic(appctx->owner); struct ist out = ist2(trash.area, 0); - size_t max = htx_free_data_space(htx); + size_t max = htx_get_max_blksz(htx, channel_htx_recv_max(chn, htx)); int ret = 1; while (appctx->st2 && appctx->st2 < ST_F_TOTAL_FIELDS) { @@ -1605,7 +1604,7 @@ static int promex_dump_back_metrics(struct appctx *appctx, struct htx *htx) struct field metric; struct channel *chn = si_ic(appctx->owner); struct ist out = ist2(trash.area, 0); - size_t max = htx_free_data_space(htx); + size_t max = htx_get_max_blksz(htx, channel_htx_recv_max(chn, htx)); int ret = 1; uint32_t weight; @@ -1824,7 +1823,7 @@ static int promex_dump_srv_metrics(struct appctx *appctx, struct htx *htx) struct field metric; struct channel *chn = si_ic(appctx->owner); struct ist out = ist2(trash.area, 0); - size_t max = htx_free_data_space(htx); + size_t max = htx_get_max_blksz(htx, channel_htx_recv_max(chn, htx)); int ret = 1; uint32_t weight; @@ -2153,7 +2152,6 @@ static void promex_appctx_handle_io(struct appctx *appctx) int ret; res_htx = htx_from_buf(&res->buf); - if (unlikely(si->state == SI_ST_DIS || si->state == SI_ST_CLO)) goto out;