diff --git a/bin/varnishd/http2/cache_http2.h b/bin/varnishd/http2/cache_http2.h index 0bb485fde13..d3cd4673d28 100644 --- a/bin/varnishd/http2/cache_http2.h +++ b/bin/varnishd/http2/cache_http2.h @@ -193,6 +193,13 @@ struct h2_sess { VTAILQ_HEAD(,h2_req) txqueue; h2_error error; + + // rst rate limit parameters, copied from h2_* parameters + vtim_dur rapid_reset; + int64_t rapid_reset_limit; + vtim_dur rapid_reset_period; + + // rst rate limit stats double rst_allowance; vtim_real last_rst; }; diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index b69b659121e..f7a104c0aae 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -336,16 +336,16 @@ h2_rx_rst_stream(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) return (0); h2_kill_req(wrk, h2, r2, h2_streamerror(vbe32dec(h2->rxf_data))); - if (cache_param->h2_rapid_reset == 0 || - cache_param->h2_rapid_reset_limit == 0) + if (h2->rapid_reset == 0 || + h2->rapid_reset_limit == 0) return (0); now = VTIM_real(); d = now - h2->last_rst; - h2->rst_allowance += (1.0 * d / cache_param->h2_rapid_reset_period) * - cache_param->h2_rapid_reset_limit; + h2->rst_allowance += (1.0 * d / h2->rapid_reset_period) * + h2->rapid_reset_limit; h2->rst_allowance = vmin_t(double, h2->rst_allowance, - cache_param->h2_rapid_reset_limit); + h2->rapid_reset_limit); h2->last_rst = now; if (h2->rst_allowance < 1.0) { @@ -354,7 +354,7 @@ h2_rx_rst_stream(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) Lck_Unlock(&h2->sess->mtx); return (H2CE_ENHANCE_YOUR_CALM); } - if (d < cache_param->h2_rapid_reset) + if (d < h2->rapid_reset) h2->rst_allowance -= 1.0; return (0); diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index cecb0214c03..9f8253aded7 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -127,7 +127,12 @@ h2_init_sess(struct sess *sp, h2_local_settings(&h2->local_settings); h2->remote_settings = H2_proto_settings; h2->decode = decode; - h2->rst_allowance = cache_param->h2_rapid_reset_limit; + + h2->rapid_reset = cache_param->h2_rapid_reset; + h2->rapid_reset_limit = cache_param->h2_rapid_reset_limit; + h2->rapid_reset_period = cache_param->h2_rapid_reset_period; + + h2->rst_allowance = h2->rapid_reset_limit; h2->last_rst = sp->t_open; AZ(isnan(h2->last_rst));