[6.0] fc857a6c5 http2: New H2_ERROR_MATCH() helper macro

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Thu Apr 4 14:33:11 UTC 2024


commit fc857a6c599b7a2b4aa8745ba30885ee8b6430e8
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Thu Mar 28 15:56:21 2024 +0100

    http2: New H2_ERROR_MATCH() helper macro

diff --git a/bin/varnishd/http2/cache_http2.h b/bin/varnishd/http2/cache_http2.h
index 26cba9055..00fbe7c6b 100644
--- a/bin/varnishd/http2/cache_http2.h
+++ b/bin/varnishd/http2/cache_http2.h
@@ -48,6 +48,9 @@ struct h2_error_s {
 
 typedef const struct h2_error_s *h2_error;
 
+#define H2_ERROR_MATCH(err, target)			\
+	((err) != NULL && (err)->val == (target)->val)
+
 #define H2_CUSTOM_ERRORS
 #define H2EC1(U,v,g,r,d) extern const struct h2_error_s H2CE_##U[1];
 #define H2EC2(U,v,g,r,d) extern const struct h2_error_s H2SE_##U[1];
diff --git a/bin/varnishd/http2/cache_http2_send.c b/bin/varnishd/http2/cache_http2_send.c
index c1e03a5dc..6ae45d136 100644
--- a/bin/varnishd/http2/cache_http2_send.c
+++ b/bin/varnishd/http2/cache_http2_send.c
@@ -448,6 +448,6 @@ H2_Send(struct worker *wrk, struct h2_req *r2, h2_frame ftyp, uint8_t flags,
 	h2_send(wrk, r2, ftyp, flags, len, ptr, counter);
 
 	h2e = h2_errcheck(r2, r2->h2sess);
-	if (h2e != NULL && h2e->val == H2SE_CANCEL->val)
+	if (H2_ERROR_MATCH(h2e, H2SE_CANCEL))
 		H2_Send_RST(wrk, r2->h2sess, r2, r2->stream, h2e);
 }


More information about the varnish-commit mailing list