Mailing List Archive

[master] 884f8b316 http2_proto: Make h2_stream_tmo() return an error
commit 884f8b3164a8b598cb7960f8379f5504c70b6c62
Author: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
Date: Thu Nov 16 13:16:15 2023 +0100

http2_proto: Make h2_stream_tmo() return an error

diff --git a/bin/varnishd/http2/cache_http2.h b/bin/varnishd/http2/cache_http2.h
index f73b5657e..0ca9eeb78 100644
--- a/bin/varnishd/http2/cache_http2.h
+++ b/bin/varnishd/http2/cache_http2.h
@@ -255,7 +255,7 @@ void H2_Send(struct worker *, struct h2_req *, h2_frame type, uint8_t flags,

/* cache_http2_proto.c */
struct h2_req * h2_new_req(struct h2_sess *, unsigned stream, struct req *);
-int h2_stream_tmo(struct h2_sess *, const struct h2_req *, vtim_real);
+h2_error h2_stream_tmo(struct h2_sess *, const struct h2_req *, vtim_real);
void h2_del_req(struct worker *, struct h2_req *);
void h2_kill_req(struct worker *, struct h2_sess *, struct h2_req *, h2_error);
int h2_rxframe(struct worker *, struct h2_sess *);
diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c
index 58e67ecef..454a78cbe 100644
--- a/bin/varnishd/http2/cache_http2_proto.c
+++ b/bin/varnishd/http2/cache_http2_proto.c
@@ -1285,10 +1285,10 @@ h2_procframe(struct worker *wrk, struct h2_sess *h2, h2_frame h2f)
return (NULL);
}

-int
+h2_error
h2_stream_tmo(struct h2_sess *h2, const struct h2_req *r2, vtim_real now)
{
- int r = 0;
+ h2_error h2e = NULL;

CHECK_OBJ_NOTNULL(h2, H2_SESS_MAGIC);
CHECK_OBJ_NOTNULL(r2, H2_REQ_MAGIC);
@@ -1301,36 +1301,36 @@ h2_stream_tmo(struct h2_sess *h2, const struct h2_req *r2, vtim_real now)
AN(r2->t_winupd);

if (r2->t_winupd == 0 && r2->t_send == 0)
- return (0);
+ return (NULL);

if (isnan(now) || (r2->t_winupd != 0 &&
now - r2->t_winupd > SESS_TMO(h2->sess, idle_send_timeout))) {
VSLb(h2->vsl, SLT_Debug,
"H2: stream %u: Hit idle_send_timeout waiting for"
" WINDOW_UPDATE", r2->stream);
- r = 1;
+ h2e = H2SE_CANCEL;
}

- if (r == 0 && r2->t_send != 0 &&
+ if (h2e == NULL && r2->t_send != 0 &&
now - r2->t_send > SESS_TMO(h2->sess, send_timeout)) {
VSLb(h2->vsl, SLT_Debug,
"H2: stream %u: Hit send_timeout", r2->stream);
- r = 1;
+ h2e = H2SE_CANCEL;
}

- return (r);
+ return (h2e);
}

-static int
+static h2_error
h2_stream_tmo_unlocked(struct h2_sess *h2, const struct h2_req *r2)
{
- int r;
+ h2_error h2e;

Lck_Lock(&h2->sess->mtx);
- r = h2_stream_tmo(h2, r2, h2->sess->t_idle);
+ h2e = h2_stream_tmo(h2, r2, h2->sess->t_idle);
Lck_Unlock(&h2->sess->mtx);

- return (r);
+ return (h2e);
}

/*
_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit