[master] 75c344d20 vtc_http2: Track the peer window of h2 streams
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Tue Jan 31 11:47:07 UTC 2023
commit 75c344d20437e103520810e738b350eeb92be685
Author: Walid Boudebouda <walid.boudebouda at gmail.com>
Date: Tue Jan 31 11:17:32 2023 +0100
vtc_http2: Track the peer window of h2 streams
Signed-off-by: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
diff --git a/bin/varnishtest/vtc_http.h b/bin/varnishtest/vtc_http.h
index 51028c1ef..a5d43001e 100644
--- a/bin/varnishtest/vtc_http.h
+++ b/bin/varnishtest/vtc_http.h
@@ -91,6 +91,7 @@ struct http {
struct hpk_ctx *encctx;
struct hpk_ctx *decctx;
struct h2_window h2_win_self[1];
+ struct h2_window h2_win_peer[1];
};
int http_process(struct vtclog *vl, struct vtc_sess *vsp, const char *spec,
diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c
index 08209234d..a3470282e 100644
--- a/bin/varnishtest/vtc_http2.c
+++ b/bin/varnishtest/vtc_http2.c
@@ -107,6 +107,7 @@ struct stream {
pthread_t tp;
struct http *hp;
int64_t win_self;
+ int64_t win_peer;
int wf;
VTAILQ_HEAD(, frame) fq;
@@ -321,7 +322,7 @@ clean_frame(struct frame **fp)
}
static void
-write_frame(const struct stream *sp, const struct frame *f, const unsigned lock)
+write_frame(struct stream *sp, const struct frame *f, const unsigned lock)
{
struct http *hp;
ssize_t l;
@@ -340,6 +341,11 @@ write_frame(const struct stream *sp, const struct frame *f, const unsigned lock)
f->type < TYPE_MAX ? h2_types[f->type] : "?",
f->type, f->flags, f->size);
+ if (f->type == TYPE_DATA) {
+ sp->win_peer -= f->size;
+ hp->h2_win_peer->size -= f->size;
+ }
+
if (lock)
AZ(pthread_mutex_lock(&hp->mtx));
l = write(hp->sess->fd, hdr, sizeof(hdr));
@@ -2398,6 +2404,50 @@ cmd_rxpush(CMD_ARGS)
s->frame = f;
}
+/* SECTION: stream.spec.winup_rxwinup rxwinup
+ *
+ * Receive a WINDOW_UPDATE frame.
+ */
+static void
+cmd_rxwinup(CMD_ARGS)
+{
+ struct stream *s;
+ struct frame *f;
+
+ CAST_OBJ_NOTNULL(s, priv, STREAM_MAGIC);
+ s->frame = rxstuff(s);
+ CAST_OBJ_NOTNULL(f, s->frame, FRAME_MAGIC);
+ CHKFRAME(f->type, TYPE_WINDOW_UPDATE, 0, *av);
+ if (s->id == 0)
+ s->hp->h2_win_peer->size += s->frame->md.winup_size;
+ s->win_peer += s->frame->md.winup_size;
+}
+
+/* SECTION: stream.spec.settings_rxsettings rxsettings
+ *
+ * Receive a SETTINGS frame.
+ */
+static void
+cmd_rxsettings(CMD_ARGS)
+{
+ struct stream *s, *_s;
+ uint32_t val = 0;
+ struct http *hp;
+ struct frame *f;
+
+ CAST_OBJ_NOTNULL(s, priv, STREAM_MAGIC);
+ CAST_OBJ_NOTNULL(hp, s->hp, HTTP_MAGIC);
+ s->frame = rxstuff(s);
+ CAST_OBJ_NOTNULL(f, s->frame, FRAME_MAGIC);
+ CHKFRAME(f->type, TYPE_SETTINGS, 0, *av);
+ if (! isnan(f->md.settings[SETTINGS_INITIAL_WINDOW_SIZE])) {
+ val = f->md.settings[SETTINGS_INITIAL_WINDOW_SIZE];
+ VTAILQ_FOREACH(_s, &hp->streams, list)
+ _s->win_peer += (val - hp->h2_win_peer->init);
+ hp->h2_win_peer->init = val;
+ }
+}
+
#define RXFUNC(lctype, upctype) \
static void \
cmd_rx ## lctype(CMD_ARGS) { \
@@ -2425,12 +2475,6 @@ RXFUNC(prio, PRIORITY)
*/
RXFUNC(rst, RST_STREAM)
-/* SECTION: stream.spec.settings_rxsettings rxsettings
- *
- * Receive a SETTINGS frame.
- */
-RXFUNC(settings,SETTINGS)
-
/* SECTION: stream.spec.ping_rxping rxping
*
* Receive a PING frame.
@@ -2443,12 +2487,6 @@ RXFUNC(ping, PING)
*/
RXFUNC(goaway, GOAWAY)
-/* SECTION: stream.spec.winup_rxwinup rxwinup
- *
- * Receive a WINDOW_UPDATE frame.
- */
-RXFUNC(winup, WINDOW_UPDATE)
-
/* SECTION: stream.spec.frame_rxframe
*
* Receive a frame, any frame.
@@ -2602,6 +2640,7 @@ stream_new(const char *name, struct http *h)
AN(s->name);
VTAILQ_INIT(&s->fq);
s->win_self = h->h2_win_self->init;
+ s->win_peer = h->h2_win_peer->init;
s->vl = vtc_logopen("%s.%s", h->sess->name, name);
vtc_log_set_cmd(s->vl, stream_cmds);
@@ -2850,7 +2889,8 @@ start_h2(struct http *hp)
VTAILQ_INIT(&hp->streams);
hp->h2_win_self->init = 0xffff;
hp->h2_win_self->size = 0xffff;
-
+ hp->h2_win_peer->init = 0xffff;
+ hp->h2_win_peer->size = 0xffff;
hp->h2 = 1;
hp->decctx = HPK_NewCtx(4096);
More information about the varnish-commit
mailing list