[6.0] e006849e6 http2_proto: Make h2_stream_tmo() return an error

Simon Stridsberg simon.stridsberg at varnish-software.com
Mon Mar 18 18:20:04 UTC 2024


commit e006849e694633767ccc8ad427c673bd3b294794
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Thu Nov 16 13:16:15 2023 +0100

    http2_proto: Make h2_stream_tmo() return an error
    
    Conflicts:
            bin/varnishd/http2/cache_http2.h
            bin/varnishd/http2/cache_http2_proto.c

diff --git a/bin/varnishd/http2/cache_http2.h b/bin/varnishd/http2/cache_http2.h
index 4020b2887..e5cf6a224 100644
--- a/bin/varnishd/http2/cache_http2.h
+++ b/bin/varnishd/http2/cache_http2.h
@@ -257,7 +257,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(const struct worker *, 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 8ef3b9a90..1372074cb 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 > cache_param->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 > cache_param->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);
 }
 
 /*


More information about the varnish-commit mailing list